Esempio n. 1
0
        public bool Activate(bool activateDependencies)
        {
            if (MissingDependencies.Count > 0)
            {
                return(false);
            }

            if (IsActive)
            {
                return(true);
            }

            //check whether all predececcors are active -> actual plugin depends on
            if (activateDependencies)
            {
                //try to activate depend plugins
                if (Predecessors.Count(elem => !((PluginNode)elem).Activate(true)) > 0)
                {
                    return(false);
                }
            }
            else
            {
                //just count inactive plugins
                if (Predecessors.Count(elem => !((PluginNode)elem).IsActive) > 0)
                {
                    return(false);
                }
            }

            PluginInstance = Graph.PluginManager.CreatePluginInstance(Value);

            if (PluginInstance == null)
            {
                return(false);
            }

            Graph.NotifyPlugins(PluginInstance, PluginNotification.Created);

            PluginContext = Graph.PluginManager.CreatePluginContext(PluginInstance);

            PluginInstance.ActivatePlugin(PluginContext);

            IsActive = true;

            Graph.NotifyPlugins(PluginInstance, PluginNotification.Activated);

            return(true);
        }