public static MethodInfo GetMethod(this IDotnetExpander expander, object value, string methodName) { string assemblyName, typeName, valueName; expander.ParseName(value, out assemblyName, out typeName, out valueName); return(expander.GetMethod(assemblyName, typeName, methodName)); }
public static T GetMethodAttribute <T>(this IDotnetExpander expander, string assemblyName, string typeName, string methodName) where T : Attribute { return(Ex.Cache.Read("methodattribute", assemblyName ?? "", typeName ?? "", methodName ?? "", () => { var methodInfo = expander.GetMethod(assemblyName, typeName, methodName); var customAttributes = methodInfo.GetCustomAttributes(typeof(T), true); return customAttributes.Length > 0 ? customAttributes[0] as T : default(T); })); }
public static Attribute[] GetMethodAttributes(this IDotnetExpander expander, string assemblyName, string typeName, string methodName) { return(Ex.Cache.Read("methodattributes", assemblyName ?? "", typeName ?? "", methodName ?? "", () => { var methodInfo = expander.GetMethod(assemblyName, typeName, methodName); if (methodInfo == null) { return new Attribute[0]; } var list = new List <Attribute>(); foreach (var item in methodInfo.GetCustomAttributes(true)) { var attribute = item as Attribute; if (attribute != null) { list.Add(attribute); } } return list.ToArray(); })); }
public static MethodInfo GetMethod <T>(this IDotnetExpander expander, string methodName) { return(expander.GetMethod(typeof(T), methodName)); }