ana sayfa > C#, MVC, Reflection > MVC Get – Controllers, Actions, Attributes and Return Types – 2

MVC Get – Controllers, Actions, Attributes and Return Types – 2

Çarşamba, 07 Eyl 2016 yorum ekle yorumlara git
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());
           }
      }
}

 

Categories: C#, MVC, Reflection Tags: , ,
  1. şimdilik yorum yok.
  1. şimdilik geri bağlantı yok
yorum yapabilmek için giriş yapmalısınız