Esempio n. 1
0
            private static void BuildEditorMap()
            {
                if (_editorMap == null)
                {
                    _editorMap = new Dictionary <Type, SerializedObjectEditorAttribute.RenderPropertiesDelegate>();

                    Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();

                    foreach (Assembly assembly in assemblies)
                    {
                        Type[] types = assembly.GetTypes();

                        foreach (Type type in types)
                        {
                            SerializedObjectEditorAttribute attribute = SystemUtils.GetAttribute <SerializedObjectEditorAttribute>(type);

                            if (attribute != null)
                            {
                                if (_editorMap.ContainsKey(attribute.ObjectType))
                                {
                                    throw new Exception("Can't initialize XmlObjectEditorAttribute for " + type.FullName + " as already have a editor for type " + attribute.ObjectType);
                                }

                                _editorMap[attribute.ObjectType] = SystemUtils.GetStaticMethodAsDelegate <SerializedObjectEditorAttribute.RenderPropertiesDelegate>(type, attribute.OnRenderPropertiesMethod);
                            }
                        }
                    }
                }
            }
            private static void BuildEditorMap()
            {
                if (_editorMap == null)
                {
                    _editorMap = new Dictionary <Type, SerializedObjectEditorAttribute.RenderPropertiesDelegate>();

                    Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();

                    foreach (Assembly assembly in assemblies)
                    {
                        Type[] types = assembly.GetTypes();

                        foreach (Type type in types)
                        {
                            SerializedObjectEditorAttribute attribute = SystemUtils.GetAttribute <SerializedObjectEditorAttribute>(type);

                            if (attribute != null)
                            {
                                SerializedObjectEditorAttribute.RenderPropertiesDelegate func = SystemUtils.GetStaticMethodAsDelegate <SerializedObjectEditorAttribute.RenderPropertiesDelegate>(type, attribute.OnRenderPropertiesMethod);

                                _editorMap[attribute.ObjectType] = func;


                                if (attribute.UseForChildTypes)
                                {
                                    Type[] childTypes = SystemUtils.GetAllSubTypes(attribute.ObjectType);

                                    foreach (Type childType in childTypes)
                                    {
                                        if (!_editorMap.ContainsKey(childType))
                                        {
                                            _editorMap[childType] = func;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }