Exemple #1
0
        public static MethodListOption CreateMethodListOption(Type attributeType)
        {
            MethodListOption methodListOption = new MethodListOption();

            methodListOption.methodInfoList = new List <MethodInfo>();
            methodListOption.methodInfoList.Add(null);
            ReflectionUtility.ForeachClassTypeFromAssembly((type) => {
                MethodInfo[] methodInfos = type.GetMethods(BindingFlags.Static | BindingFlags.Public);
                foreach (MethodInfo methodInfo in methodInfos)
                {
                    if (methodInfo.IsDefined(attributeType, false) && !methodInfo.IsGenericMethod && methodInfo.GetParameters().Length <= MethodAction.MaxParameterCount)
                    {
                        methodListOption.methodInfoList.Add(methodInfo);
                    }
                }
                return(true);
            });

            methodListOption.methodInfoName    = new string[methodListOption.methodInfoList.Count];
            methodListOption.methodInfoName[0] = "None";
            for (int i = 1; i < methodListOption.methodInfoList.Count; i++)
            {
                methodListOption.methodInfoName[i] = FormatMethodName(methodListOption.methodInfoList[i]);
            }
            return(methodListOption);
        }
 static SerializableEnumDrawer()
 {
     ReflectionUtility.ForeachClassTypeFromAssembly((type) => {
         if (type.IsEnum && type.IsPublic)
         {
             enumTypeList.Add(type);
         }
         return(true);
     });
     enumTypeList.Sort((x, y) => x.AssemblyQualifiedName.CompareTo(y.AssemblyQualifiedName));
 }
        static PropertyEnumPropertyDrawer()
        {
            ReflectionUtility.ForeachClassTypeFromAssembly((type) => {
                if (type.IsEnum && type.IsDefined(typeof(PropertyToEnumAttribute), false))
                {
                    string[] names = Enum.GetNames(type);
                    if (names.Length > 0)
                    {
                        PropertyToEnumAttribute attribute = Attribute.GetCustomAttribute(type, typeof(PropertyToEnumAttribute)) as PropertyToEnumAttribute;

                        Content content;
                        if (!enumMap.TryGetValue(attribute.classType, out content))
                        {
                            content = new Content();
                            enumMap.Add(attribute.classType, content);
                        }

                        if (attribute.propertyName == null)
                        {
                            content.enumValues = new string[names.Length];
                            Array.Copy(names, content.enumValues, content.enumValues.Length);
                        }
                        else
                        {
                            if (content.propertyEnumMap == null)
                            {
                                content.propertyEnumMap = new Dictionary <string, string[]>();
                            }
                            if (!content.propertyEnumMap.ContainsKey(attribute.propertyName))
                            {
                                string[] enumValues = new string[names.Length];
                                Array.Copy(names, enumValues, enumValues.Length);
                                content.propertyEnumMap.Add(attribute.propertyName, enumValues);
                            }
                        }
                    }
                }
                return(true);
            });
        }