Assembly assembly = Assembly.GetExecutingAssembly();
IEnumerable<Type> types = assembly.GetTypes()
.Where(
type =>
typeof(Controller).IsAssignableFrom(type) &&
type.Name.Replace("Controller", "") == controllerName)
.OrderBy(x => x.Name);
foreach (Type cls in types)
{
HelpAttribute helpAttribute = Attribute.GetCustomAttribute(cls, typeof(HelpAttribute)) as HelpAttribute;
url = helpAttribute != null ? helpAttribute.Url : string.Empty;
........
}
Assembly assembly = Assembly.LoadFrom(sAssemblyFileName)
IEnumerable<Type> types = assembly.GetTypes().Where(type => typeof(Controller).IsAssignableFrom(type)).OrderBy(x => x.Name);
foreach (Type cls in types)
{
list.Add(cls.Name.Replace("Controller", ""));
IEnumerable<MemberInfo> memberInfo = cls.GetMethods(BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public).Where(m => !m.GetCustomAttributes(typeof(System.Runtime.CompilerServices.CompilerGeneratedAttribute), true).Any()).OrderBy(x => x.Name);
foreach (MemberInfo method in memberInfo)
{
if (method.ReflectedType.IsPublic && !method.IsDefined(typeof(NonActionAttribute)))
{
list.Add("\t" + method.Name.ToString());
}
}
}
Assembly asm = Assembly.GetAssembly(typeof(MyWebDll.MvcApplication));
var controlleractionlist = asm.GetTypes()
.Where(type=> typeof(System.Web.Mvc.Controller).IsAssignableFrom(type))
.SelectMany(type => type.GetMethods(BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public))
.Where(m => !m.GetCustomAttributes(typeof( System.Runtime.CompilerServices.CompilerGeneratedAttribute), true).Any())
.Select(x => new {Controller = x.DeclaringType.Name, Action = x.Name, ReturnType = x.ReturnType.Name, Attributes = String.Join(",", x.GetCustomAttributes().Select(a => a.GetType().Name.Replace("Attribute",""))) })
.OrderBy(x=>x.Controller).ThenBy(x => x.Action).ToList();
List<T> olan bir veriyi html çıktı olarak hazırlama…
devamını oku…
public static T SetXmlDataToViewModel&lt;T&gt;(T oViewModel, string xmlData)
{
if (string.IsNullOrEmpty(xmlData))
{
return oViewModel;
}
XDocument dataXmlDoc = XDocument.Parse(xmlData);
foreach (var prop in typeof(T).GetProperties())
{
if (dataXmlDoc.Descendants().SingleOrDefault(p =&gt; p.Name.LocalName == prop.Name) != null)
prop.SetValue(oViewModel, Convert.ChangeType(dataXmlDoc.Descendants().SingleOrDefault(p =&gt; p.Name.LocalName == prop.Name).Value, prop.PropertyType));
}
return oViewModel;
}