Beispiel #1
0
        public static FieldInfo GetField(this IDotnetExpander expander, string name, string fieldName)
        {
            string assemblyName, typeName, value;

            expander.ParseName(name, out assemblyName, out typeName, out value);
            return(expander.GetField(assemblyName, typeName, fieldName));
        }
Beispiel #2
0
 public static T GetFieldAttribute <T>(this IDotnetExpander expander, string assemblyName, string typeName, string fieldName) where T : Attribute
 {
     return(Ex.Cache.Read("fieldattribute", assemblyName ?? "", typeName ?? "", fieldName ?? "", () =>
     {
         var fieldInfo = expander.GetField(assemblyName, typeName, fieldName);
         var customAttributes = fieldInfo.GetCustomAttributes(typeof(T), true);
         return customAttributes.Length > 0 ? customAttributes[0] as T : default(T);
     }));
 }
Beispiel #3
0
 public static Attribute[] GetFieldAttributes(this IDotnetExpander expander, string assemblyName, string typeName, string fieldName)
 {
     return(Ex.Cache.Read("fieldattributes", assemblyName ?? "", typeName ?? "", fieldName ?? "", () =>
     {
         var fieldInfo = expander.GetField(assemblyName, typeName, fieldName);
         if (fieldInfo == null)
         {
             return new Attribute[0];
         }
         var list = new List <Attribute>();
         foreach (var item in fieldInfo.GetCustomAttributes(true))
         {
             var attribute = item as Attribute;
             if (attribute != null)
             {
                 list.Add(attribute);
             }
         }
         return list.ToArray();
     }));
 }
Beispiel #4
0
 public static FieldInfo GetField <T>(this IDotnetExpander expander, string fieldName)
 {
     return(expander.GetField(typeof(T), fieldName));
 }