Пример #1
0
        public static PropertyInfo GetProperty(this IDotnetExpander expander, string name, string propertyName)
        {
            string assemblyName, typeName, value;

            expander.ParseName(name, out assemblyName, out typeName, out value);
            return(expander.GetProperty(assemblyName, typeName, propertyName));
        }
Пример #2
0
 public static T GetPropertyAttribute <T>(this IDotnetExpander expander, string assemblyName, string typeName, string propertyName) where T : Attribute
 {
     return(Ex.Cache.Read("propertyattribute", assemblyName ?? "", typeName ?? "", propertyName ?? "", () =>
     {
         var propertyInfo = expander.GetProperty(assemblyName, typeName, propertyName);
         var customAttributes = propertyInfo?.GetCustomAttributes(typeof(T), true);
         return customAttributes?.Length > 0 ? customAttributes[0] as T : default(T);
     }));
 }
Пример #3
0
 public static Attribute[] GetPropertyAttributes(this IDotnetExpander expander, string assemblyName, string typeName, string propertyName)
 {
     return(Ex.Cache.Read("propertyattributes", assemblyName ?? "", typeName ?? "", propertyName ?? "", () =>
     {
         var propertyInfo = expander.GetProperty(assemblyName, typeName, propertyName);
         if (propertyInfo == null)
         {
             return new Attribute[0];
         }
         var list = new List <Attribute>();
         foreach (var item in propertyInfo.GetCustomAttributes(true))
         {
             var attribute = item as Attribute;
             if (attribute != null)
             {
                 list.Add(attribute);
             }
         }
         return list.ToArray();
     }));
 }
Пример #4
0
 public static PropertyInfo GetProperty <T>(this IDotnetExpander expander, string propertyName)
 {
     return(expander.GetProperty(typeof(T), propertyName));
 }