Exemplo n.º 1
0
        static HashSet <Type> GetCustomTypeDelegates()
        {
            BindType[]     list    = CustomSettings.customTypeList;
            HashSet <Type> set     = new HashSet <Type>();
            BindingFlags   binding = BindingFlags.Public | BindingFlags.Static | BindingFlags.IgnoreCase | BindingFlags.Instance;

            for (int i = 0; i < list.Length; i++)
            {
                Type           type    = list[i].type;
                FieldInfo[]    fields  = type.GetFields(BindingFlags.GetField | BindingFlags.SetField | binding);
                PropertyInfo[] props   = type.GetProperties(BindingFlags.GetProperty | BindingFlags.SetProperty | binding);
                MethodInfo[]   methods = null;

                if (type.IsInterface)
                {
                    methods = type.GetMethods();
                }
                else
                {
                    methods = type.GetMethods(BindingFlags.Instance | binding);
                }

                for (int j = 0; j < fields.Length; j++)
                {
                    Type t = fields[j].FieldType;

                    if (ToLuaDevExport.IsDelegateType(t))
                    {
                        set.Add(t);
                    }
                }

                for (int j = 0; j < props.Length; j++)
                {
                    Type t = props[j].PropertyType;

                    if (ToLuaDevExport.IsDelegateType(t))
                    {
                        set.Add(t);
                    }
                }

                for (int j = 0; j < methods.Length; j++)
                {
                    MethodInfo m = methods[j];

                    if (m.IsGenericMethod)
                    {
                        continue;
                    }

                    ParameterInfo[] pifs = m.GetParameters();

                    for (int k = 0; k < pifs.Length; k++)
                    {
                        Type t = pifs[k].ParameterType;
                        if (t.IsByRef)
                        {
                            t = t.GetElementType();
                        }

                        if (ToLuaDevExport.IsDelegateType(t))
                        {
                            set.Add(t);
                        }
                    }
                }
            }

            return(set);
        }