コード例 #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
ファイル: HeliosDescriptor.cs プロジェクト: appsou/Helios
 public HeliosDescriptor(Type type, HeliosControlAttribute attribute)
 {
     _controlType      = type;
     _controlAttribute = attribute;
 }