Пример #1
0
        public static string GetFilterGUIName(IFilter filter)
        {
            CustomFilter attr =
                filter.GetType().GetCustomAttributes(typeof(CustomFilter), false).FirstOrDefault() as CustomFilter;

            return(attr.Name);
        }
Пример #2
0
        public static bool HasValidCustomFilterAttribute(Type t)
        {
            CustomFilter attr =
                t.GetCustomAttributes(typeof(CustomFilter), false).FirstOrDefault() as CustomFilter;

            return(attr != null && !string.IsNullOrEmpty(attr.Name));
        }
Пример #3
0
 public static string GetPrefabBuilderGUIName(string className)
 {
     if (className != null)
     {
         var type = Type.GetType(className);
         if (type != null)
         {
             CustomFilter attr =
                 type.GetCustomAttributes(typeof(CustomFilter), false).FirstOrDefault() as CustomFilter;
             if (attr != null)
             {
                 return(attr.Name);
             }
         }
     }
     return(string.Empty);
 }
Пример #4
0
        public static Dictionary <string, string> GetAttributeAssemblyQualifiedNameMap()
        {
            if (s_attributeAssemblyQualifiedNameMap == null)
            {
                // attribute name or class name : class name
                s_attributeAssemblyQualifiedNameMap = new Dictionary <string, string>();

                var allFilters = new List <Type>();

                foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
                {
                    var filters = assembly.GetTypes()
                                  .Where(t => !t.IsInterface)
                                  .Where(t => typeof(IFilter).IsAssignableFrom(t));
                    allFilters.AddRange(filters);
                }

                foreach (var type in allFilters)
                {
                    // set attribute-name as key of dict if atribute is exist.
                    CustomFilter attr =
                        type.GetCustomAttributes(typeof(CustomFilter), true).FirstOrDefault() as CustomFilter;

                    var typename = type.AssemblyQualifiedName;

                    if (attr != null)
                    {
                        if (!s_attributeAssemblyQualifiedNameMap.ContainsKey(attr.Name))
                        {
                            s_attributeAssemblyQualifiedNameMap[attr.Name] = typename;
                        }
                    }
                    else
                    {
                        s_attributeAssemblyQualifiedNameMap[typename] = typename;
                    }
                }
            }
            return(s_attributeAssemblyQualifiedNameMap);
        }