Пример #1
0
        internal void RegisterModule(Assembly asm)
        {
            if (asm != null)
            {
                try
                {
                    string moduleName = asm.GetName().Name;

                    foreach (Type type in asm.GetTypes())
                    {
                        if (type.IsAbstract)
                        {
                            continue;
                        }
                        object[] attrs = type.GetCustomAttributes(false);
                        foreach (object attribute in attrs)
                        {
                            HeliosControlAttribute controlAttribute = attribute as HeliosControlAttribute;
                            if (controlAttribute != null)
                            {
                                ConfigManager.LogManager.LogDebug("Control found " + type.Name);
                                _controlDescriptors.Add(new HeliosDescriptor(type, controlAttribute));
                            }

                            HeliosInterfaceAttribute interfaceAttribute = attribute as HeliosInterfaceAttribute;
                            if (interfaceAttribute != null)
                            {
                                ConfigManager.LogManager.LogDebug("Interface found " + type.Name);
                                _interfaceDescriptors.Add(new HeliosInterfaceDescriptor(type, interfaceAttribute));
                            }

                            HeliosUnitConverterAttribute converterAttribute = attribute as HeliosUnitConverterAttribute;
                            if (converterAttribute != null)
                            {
                                ConfigManager.LogManager.LogDebug("Converter found " + type.Name);
                                _converters.Add((BindingValueUnitConverter)Activator.CreateInstance(type));
                            }

                            HeliosPropertyEditorAttribute editorAttribute = attribute as HeliosPropertyEditorAttribute;
                            if (editorAttribute != null)
                            {
                                ConfigManager.LogManager.LogDebug("Property editor found " + type.Name);
                                HeliosPropertyEditorDescriptorCollection editors;
                                if (_propertyEditors.ContainsKey(editorAttribute.TypeIdentifier))
                                {
                                    editors = _propertyEditors[editorAttribute.TypeIdentifier];
                                }
                                else
                                {
                                    editors = new HeliosPropertyEditorDescriptorCollection();
                                    _propertyEditors.Add(editorAttribute.TypeIdentifier, editors);
                                }

                                editors.Add(new HeliosPropertyEditorDescriptor(type, editorAttribute));
                            }
                        }
                    }
                }
                catch (ReflectionTypeLoadException e)
                {
                    ConfigManager.LogManager.LogError("Failed reflecting assembly " + asm.FullName, e);
                }
                catch (Exception e)
                {
                    ConfigManager.LogManager.LogError("Failed adding module " + asm.FullName, e);
                }
            }
        }
Пример #2
0
 public HeliosInterfaceDescriptor(Type type, HeliosInterfaceAttribute attribute)
 {
     _interfaceType      = type;
     _interfaceAttribute = attribute;
 }