Beispiel #1
0
        internal void RegisterModule(Assembly asm)
        {
            if (asm == null)
            {
                return;
            }

            try
            {
                foreach (Type type in asm.GetTypes())
                {
                    if (type.IsAbstract)
                    {
                        continue;
                    }
                    object[] attrs = type.GetCustomAttributes(false);
                    foreach (object attribute in attrs)
                    {
                        switch (attribute)
                        {
                        case HeliosControlAttribute controlAttribute:
                            Logger.Debug("Control found " + type.Name);
                            ControlDescriptors.Add(new HeliosDescriptor(type, controlAttribute));
                            break;

                        case HeliosInterfaceAttribute interfaceAttribute:
                            Logger.Debug("Interface found " + type.Name);
                            InterfaceDescriptors.Add(new HeliosInterfaceDescriptor(type, interfaceAttribute));
                            break;

                        case HeliosUnitConverterAttribute converterAttribute:
                            _ = converterAttribute;
                            Logger.Debug("Converter found " + type.Name);
                            _converters.Add((BindingValueUnitConverter)Activator.CreateInstance(type));
                            break;

                        case HeliosPropertyEditorAttribute editorAttribute:
                        {
                            Logger.Debug("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));
                            break;
                        }

                        case HeliosCapabilityEditorAttribute capabilityEditorAttribute:
                        {
                            Logger.Debug("Capability editor found " + type.Name);
                            _capabilityEditors.Add(new HeliosCapabilityEditorDescriptor(type, capabilityEditorAttribute));
                            break;
                        }

                        case HeliosToolAttribute tool:
                        {
                            _ = tool;
                            _tools.Add(new HeliosToolDescriptor(type));
                            break;
                        }
                        }
                    }
                }
            }
            catch (ReflectionTypeLoadException e)
            {
                Logger.Error(e, "Failed reflecting assembly " + asm.FullName);
            }
            catch (Exception e)
            {
                Logger.Error(e, "Failed adding module " + asm.FullName);
            }
        }
Beispiel #2
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);
                }
            }
        }
Beispiel #3
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);
                }
            }
        }