Beispiel #1
0
        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));
        }
Beispiel #2
0
 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);
     }));
 }
Beispiel #3
0
 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();
     }));
 }
Beispiel #4
0
 public static MethodInfo GetMethod <T>(this IDotnetExpander expander, string methodName)
 {
     return(expander.GetMethod(typeof(T), methodName));
 }