MethodInfo List
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Reflection; namespace RNR.Dynamics { class TransobjectUtils { public static List<MethodInfo> BuildFull(object obj) { var result = new List<MethodInfo>(); #region Listar Interfaces List<Type> interfaceList = new List<Type>(); Type baseType = obj.GetType(); Type parentType = baseType; if (baseType == null || baseType.IsInterface) { parentType = typeof(object); if (baseType != null) interfaceList.Add(baseType); } // Agregamos las interfaces hereditarias recursivamente. Type[] interfaces = interfaceList.ToArray(); foreach (Type interfaceType in interfaces) { BuildInterfaceList(interfaceType, interfaceList); } #endregion MethodInfo[] methods = baseType.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static); BuildMethodList(interfaceList, methods, result); return result; } public static void BuildInterfaceList(Type currentType, List<Type> interfaceList) { Type[] interfaces = currentType.GetInterfaces(); if (interfaces == null || interfaces.Length == 0) return; foreach (Type current in interfaces) { if (interfaceList.Contains(current)) continue; interfaceList.Add(current); BuildInterfaceList(current, interfaceList); } } public static void BuildMethodList(IEnumerable<Type> interfaceList, IEnumerable<MethodInfo> methods, List<MethodInfo> proxyList) { foreach (MethodInfo method in methods) proxyList.Add(method); foreach (Type interfaceType in interfaceList) { MethodInfo[] interfaceMethods = interfaceType.GetMethods(); foreach (MethodInfo interfaceMethod in interfaceMethods) { if (proxyList.Contains(interfaceMethod)) continue; proxyList.Add(interfaceMethod); } } } } }