Пример #1
0
        public override List <HeliosInterface> GetInterfaceInstances(HeliosInterfaceDescriptor descriptor, HeliosProfile profile)
        {
            List <HeliosInterface> interfaces = new List <HeliosInterface>();

            if (descriptor == null)
            {
                Logger.Warn("Descriptor is null passed into UniqueHeliosInterfaceFactory.GetInterfaceInstances.");
            }
            else
            {
                if (IsUnique(descriptor, profile))
                {
                    HeliosInterface newInterface = (HeliosInterface)Activator.CreateInstance(descriptor.InterfaceType);
                    if (newInterface == null)
                    {
                        Logger.Warn("New interface is null.");
                    }
                    interfaces.Add(newInterface);
                }
                else
                {
                    Logger.Debug("Unique interface already exists in profile " + descriptor.Name + ". Type: " + descriptor.InterfaceType.BaseType.Name);
                }
            }

            return(interfaces);
        }
        public override List<HeliosInterface> GetInterfaceInstances(HeliosInterfaceDescriptor descriptor, HeliosProfile profile)
        {
            List<HeliosInterface> interfaces = new List<HeliosInterface>();

            if (descriptor == null)
            {
                ConfigManager.LogManager.LogWarning("Descriptor is null passed into UniqueHeliosInterfaceFactory.GetInterfaceInstances.");
            }
            else
            {
                if (IsUnique(descriptor, profile))
                {
                    HeliosInterface newInterface = (HeliosInterface)Activator.CreateInstance(descriptor.InterfaceType);
                    if (newInterface == null)
                    {
                        ConfigManager.LogManager.LogWarning("New interface is null.");
                    }
                    interfaces.Add(newInterface);
                }
                else
                {
                    ConfigManager.LogManager.LogInfo("Unique interface already exists in profile " + descriptor.Name);
                }
            }

            return interfaces;
        }
Пример #3
0
        private object DispCreateNewObject(string type, string typeId)
        {
            switch (type)
            {
            case "Monitor":
                return(new Monitor());

            case "Visual":
                HeliosVisual visual = ConfigManager.ModuleManager.CreateControl(typeId);
                visual.Dispatcher = _dispatcher;
                return(visual);

            case "Interface":
                HeliosInterfaceDescriptor descriptor      = ConfigManager.ModuleManager.InterfaceDescriptors[typeId];
                HeliosInterface           heliosInterface = descriptor != null?descriptor.CreateInstance() : null;

                if (heliosInterface != null)
                {
                    heliosInterface.Dispatcher = _dispatcher;
                }
                return(heliosInterface);

            case "Binding":
                return(new HeliosBinding());
            }
            return(null);
        }
        private bool IsUnique(HeliosInterfaceDescriptor descriptor, HeliosProfile profile)
        {
            foreach (HeliosInterface heliosInterface in profile.Interfaces)
            {
                if (descriptor.InterfaceType.BaseType.Name != "BaseUDPInterface")
                {
                    HeliosInterfaceDescriptor interfaceDescriptor = ConfigManager.ModuleManager.InterfaceDescriptors[heliosInterface.GetType()];
                    if (interfaceDescriptor.TypeIdentifier.Equals(descriptor.TypeIdentifier))
                    {
                        // If any existing interfaces in the profile have the same type identifier do not add them.
                        return(false);
                    }
                }
                else
                {
                    string _a = heliosInterface.TypeIdentifier;
                    string _b = heliosInterface.BaseTypeIdentifier;
                    HeliosInterfaceDescriptor interfaceDescriptor = ConfigManager.ModuleManager.InterfaceDescriptors[heliosInterface.GetType()];
                    if (interfaceDescriptor.TypeIdentifier.Equals(descriptor.TypeIdentifier) || heliosInterface.BaseTypeIdentifier == "BaseUDPInterface")
                    {
                        // If any existing interfaces in the profile have the same type identifier do not add them.
                        return(false);
                    }
                }
            }

            return(true);
        }
Пример #5
0
        protected object CreateNewObject(string type, string typeId, ComponentUnsupportedSeverity ifUnsupported = ComponentUnsupportedSeverity.Error)
        {
            switch (type)
            {
            case "Monitor":
                return(new Monitor());

            case "Visual":
                HeliosVisual visual = ConfigManager.ModuleManager.CreateControl(typeId);
                if (visual == null)
                {
                    Logger.Error("Ignoring control not supported by this version of Helios: " + typeId);
                    return(null);
                }
                return(visual);

            case "Interface":
                HeliosInterfaceDescriptor descriptor = ConfigManager.ModuleManager.InterfaceDescriptors[typeId];
                if (descriptor == null)
                {
                    switch (ifUnsupported)
                    {
                    case ComponentUnsupportedSeverity.Error:
                        Logger.Error("Ignoring interface not supported by this version of Helios: {TypeId}; bindings to this interface will fail", typeId);
                        return(null);

                    case ComponentUnsupportedSeverity.Warning:
                        Logger.Warn("Ignoring interface not supported by this version of Helios: {TypeId}; bindings to this interface will fail", typeId);
                        return(null);

                    case ComponentUnsupportedSeverity.Ignore:
                        Logger.Info("Ignoring interface not supported by this version of Helios: {TypeId}; bindings to this interface will be silently ignored", typeId);
                        // create a dummy interface that preserves the XML and ignores but allows writing of all bindings
                        UnsupportedInterface dummy = new UnsupportedInterface();
                        dummy.RepresentedTypeIdentifier = typeId;

                        // record interface type alias, but don't install it yet because we may read more instances of this interface
                        // alias will allow resolution of the unsupported class to our dummy for use in places where we try to instantiate the editor
                        HeliosInterfaceDescriptor dummyDescriptor = ConfigManager.ModuleManager.InterfaceDescriptors[UnsupportedInterface.TYPE_IDENTIFIER];
                        if (DiscoveredAliases != null)
                        {
                            DiscoveredAliases[typeId] = dummyDescriptor;
                        }
                        return(dummy);

                    default:
                        throw new ArgumentOutOfRangeException(nameof(ifUnsupported), ifUnsupported, null);
                    }
                }
                return(descriptor.CreateInstance());

            case "Binding":
                return(new HeliosBinding());
            }
            return(null);
        }
Пример #6
0
        public override List <HeliosInterface> GetAutoAddInterfaces(HeliosInterfaceDescriptor descriptor, HeliosProfile profile)
        {
            List <HeliosInterface> interfaces = new List <HeliosInterface>();

            if (descriptor != null && descriptor.AutoAdd && IsUnique(descriptor, profile))
            {
                interfaces.Add((HeliosInterface)Activator.CreateInstance(descriptor.InterfaceType));
            }

            return(interfaces);
        }
        public override List<HeliosInterface> GetAutoAddInterfaces(HeliosInterfaceDescriptor descriptor, HeliosProfile profile)
        {
            List<HeliosInterface> interfaces = new List<HeliosInterface>();

            if (descriptor != null && descriptor.AutoAdd && IsUnique(descriptor, profile))
            {
                interfaces.Add((HeliosInterface)Activator.CreateInstance(descriptor.InterfaceType));
            }

            return interfaces;
        }
Пример #8
0
        public virtual List<HeliosInterface> GetInterfaceInstances(HeliosInterfaceDescriptor descriptor, HeliosProfile profile)
        {
            List<HeliosInterface> interfaces = new List<HeliosInterface>();

            if (descriptor != null)
            {
                interfaces.Add((HeliosInterface)Activator.CreateInstance(descriptor.InterfaceType));
            }

            return interfaces;
        }
        public virtual List <HeliosInterface> GetInterfaceInstances(HeliosInterfaceDescriptor descriptor, HeliosProfile profile)
        {
            List <HeliosInterface> interfaces = new List <HeliosInterface>();

            if (descriptor != null)
            {
                interfaces.Add((HeliosInterface)Activator.CreateInstance(descriptor.InterfaceType));
            }

            return(interfaces);
        }
        private bool IsUnique(HeliosInterfaceDescriptor descriptor, HeliosProfile profile)
        {
            foreach (HeliosInterface heliosInterface in profile.Interfaces)
            {
                HeliosInterfaceDescriptor interfaceDescriptor = ConfigManager.ModuleManager.InterfaceDescriptors[heliosInterface.GetType()];
                if (interfaceDescriptor.TypeIdentifier.Equals(descriptor.TypeIdentifier))
                {
                    // If any existing interfaces in the profile have the same type identifier do not add them.
                    return false;
                }
            }

            return true;
        }
Пример #11
0
        public HeliosInterfaceEditor CreateInterfaceEditor(HeliosInterface item, HeliosProfile profile)
        {
            HeliosInterfaceEditor editor = null;

            if (item != null)
            {
                HeliosInterfaceDescriptor descriptor = _interfaceDescriptors[item.GetType()];
                if (descriptor != null && descriptor.InterfaceEditorType != null)
                {
                    editor           = (HeliosInterfaceEditor)Activator.CreateInstance(descriptor.InterfaceEditorType);
                    editor.Interface = item;
                    editor.Profile   = profile;
                }
            }
            return(editor);
        }
Пример #12
0
        private bool IsUnique(HeliosInterfaceDescriptor descriptor, HeliosProfile profile)
        {
            foreach (HeliosInterface heliosInterface in profile.Interfaces)
            {
                HeliosInterfaceDescriptor interfaceDescriptor = ConfigManager.ModuleManager.InterfaceDescriptors[heliosInterface.GetType()];
                if (interfaceDescriptor.TypeIdentifier.Equals(descriptor.TypeIdentifier))
                {
                    // If any existing interfaces in the profile have the same type identifier do not add them.
                    return(false);
                }

                // XXX this hack is going away in helios17 and interface2 branches
                if (_udpInterfaceTypes.Contains(descriptor.InterfaceType.BaseType.Name) &&
                    _udpInterfaceTypes.Contains(heliosInterface.GetType().BaseType.Name))
                {
                    // don't add descendants of BaseUDPInterface
                    return(false);
                }
            }

            return(true);
        }
Пример #13
0
        private object DispCreateNewObject(string type, string typeId)
        {
            switch (type)
            {
            case "Monitor":
                return(new Monitor());

            case "Visual":
                HeliosVisual visual = ConfigManager.ModuleManager.CreateControl(typeId);
                if (visual == null)
                {
                    ConfigManager.LogManager.LogError("Ignoring control not supported by this version of Helios: " + typeId);
                    return(null);
                }
                visual.Dispatcher = _dispatcher;
                return(visual);

            case "Interface":
                HeliosInterfaceDescriptor descriptor = ConfigManager.ModuleManager.InterfaceDescriptors[typeId];
                if (descriptor == null)
                {
                    ConfigManager.LogManager.LogError("Ignoring interface not supported by this version of Helios: " + typeId);
                    return(null);
                }
                HeliosInterface heliosInterface = descriptor != null?descriptor.CreateInstance() : null;

                if (heliosInterface != null)
                {
                    heliosInterface.Dispatcher = _dispatcher;
                }
                return(heliosInterface);

            case "Binding":
                return(new HeliosBinding());
            }
            return(null);
        }