Example #1
0
        public static string GetInspectorLabel(this FieldInfo field)
        {
            string label = AttributeUtility.GetInspectorLabel(AttributeUtility.GetCustomAttributes(field));

            if (string.IsNullOrEmpty(label))
            {
                label = System.Text.RegularExpressions.Regex.Replace(char.ToUpper(field.Name[0]) + field.Name.Substring(1), "(?<!^)_?([A-Z])", " $1");
            }
            return(label);
        }
Example #2
0
 public static T GetAttribute <T>(this FieldInfo field)
 {
     object[] objArray = AttributeUtility.GetCustomAttributes(field);
     for (int i = 0; i < (int)objArray.Length; i++)
     {
         if (objArray[i].GetType() == typeof(T) || objArray[i].GetType().IsSubclassOf(typeof(T)))
         {
             return((T)objArray[i]);
         }
     }
     return(default(T));
 }
Example #3
0
 public static bool IsSerialized(this FieldInfo field)
 {
     object[] objArray = AttributeUtility.GetCustomAttributes(field);
     for (int i = 0; i < (int)objArray.Length; i++)
     {
         if (objArray[i] is SerializeField)
         {
             return(true);
         }
     }
     return(field.IsPublic && !field.IsNotSerialized);
 }
Example #4
0
 public static bool HasAttribute(this FieldInfo field, Type attributeType)
 {
     object[] objArray = AttributeUtility.GetCustomAttributes(field);
     for (int i = 0; i < (int)objArray.Length; i++)
     {
         if (objArray[i].GetType() == attributeType || objArray[i].GetType().IsSubclassOf(attributeType))
         {
             return(true);
         }
     }
     return(false);
 }
Example #5
0
 public static string GetHelpUrl(this Type type)
 {
     object[] objArray = AttributeUtility.GetCustomAttributes(type);
     for (int i = 0; i < (int)objArray.Length; i++)
     {
         HelpUrlAttribute infoAttribute = objArray[i] as HelpUrlAttribute;
         if (infoAttribute != null)
         {
             return(infoAttribute.Url);
         }
     }
     return(string.Empty);
 }
Example #6
0
 public static string GetCategory(this Type type)
 {
     object[] objArray = AttributeUtility.GetCustomAttributes(type);
     for (int i = 0; i < (int)objArray.Length; i++)
     {
         CategoryAttribute categoryAttribute = objArray[i] as CategoryAttribute;
         if (categoryAttribute != null)
         {
             return(categoryAttribute.Category);
         }
     }
     return(string.Empty);
 }
Example #7
0
 public static string GetObsoleteMessage(this Type type)
 {
     object[] objArray = AttributeUtility.GetCustomAttributes(type);
     for (int i = 0; i < (int)objArray.Length; i++)
     {
         ObsoleteAttribute infoAttribute = objArray[i] as ObsoleteAttribute;
         if (infoAttribute != null)
         {
             return(infoAttribute.Message);
         }
     }
     return(string.Empty);
 }
Example #8
0
 public static Type GetPropertyAttribute(FieldInfo field)
 {
     return(AttributeUtility.GetPropertyAttribute(AttributeUtility.GetCustomAttributes(field)) ?? field.FieldType);
 }
Example #9
0
 public static Type GetCustomDrawerAttribute(Type type)
 {
     return(AttributeUtility.GetCustomDrawerAttribute(AttributeUtility.GetCustomAttributes(type)));
 }
Example #10
0
 public static string GetTooltip(this FieldInfo field)
 {
     return(AttributeUtility.GetTooltip(AttributeUtility.GetCustomAttributes(field)));
 }
Example #11
0
 public static string GetTooltip(this Type type)
 {
     return(AttributeUtility.GetTooltip(AttributeUtility.GetCustomAttributes(type)));
 }