예제 #1
0
 internal void SetDisabled(PluginDisabledReason r)
 {
     Debug.Assert(r != PluginDisabledReason.None);
     Debug.Assert(_configDisabledReason == PluginDisabledReason.None);
     _configDisabledReason = r;
     if (Service != null)
     {
         Service.OnPluginDisabled(this);
     }
 }
예제 #2
0
        internal void SetDisabled(ServiceDisabledReason r)
        {
            Debug.Assert(r != ServiceDisabledReason.None);
            Debug.Assert(_configDisabledReason == ServiceDisabledReason.None);
            _configDisabledReason = r;

            for (int i = 0; i < _inheritedServicesWithThis.Length - 1; ++i)
            {
                --_inheritedServicesWithThis[i].AvailableServiceCount;
            }

            if (Family.Solver.Step > ConfigurationSolverStep.OnAllPluginsAdded)
            {
                Debug.Assert(Family.AvailableServices.Contains(this));
                Family.AvailableServices.Remove(this);
            }
            ServiceData spec = FirstSpecialization;

            while (spec != null)
            {
                if (!spec.Disabled)
                {
                    spec.SetDisabled(ServiceDisabledReason.GeneralizationIsDisabled);
                }
                spec = spec.NextSpecialization;
            }
            PluginData plugin = FirstPlugin;

            while (plugin != null)
            {
                if (!plugin.Disabled)
                {
                    plugin.SetDisabled(PluginDisabledReason.ServiceIsDisabled);
                }
                plugin = plugin.NextPluginForService;
            }
            foreach (var backRef in _backReferences)
            {
                PluginDisabledReason reason = backRef.PluginData.GetDisableReasonForDisabledReference(backRef.Requirement);
                if (reason != PluginDisabledReason.None && !backRef.PluginData.Disabled)
                {
                    backRef.PluginData.SetDisabled(reason);
                }
            }
            Debug.Assert(Family.RunningService != this || _inheritedServicesWithThis.All(s => s.Disabled), "If we were the RunningService, no one else is running.");
        }
예제 #3
0
        internal PluginData(IConfigurationSolver solver, IPluginInfo p, ServiceData service, ConfigurationStatus pluginStatus, StartDependencyImpact impact = StartDependencyImpact.Unknown)
        {
            _solver              = solver;
            PluginInfo           = p;
            Service              = service;
            ConfigOriginalStatus = pluginStatus;
            switch (pluginStatus)
            {
            case ConfigurationStatus.Disabled: _configSolvedStatus = SolvedConfigurationStatus.Disabled; break;

            case ConfigurationStatus.Running: _configSolvedStatus = SolvedConfigurationStatus.Running; break;

            default: _configSolvedStatus = SolvedConfigurationStatus.Runnable; break;
            }
            _configSolvedStatusReason = PluginRunningRequirementReason.Config;

            RawConfigSolvedImpact = ConfigOriginalImpact = impact;
            if (RawConfigSolvedImpact == StartDependencyImpact.Unknown && Service != null)
            {
                RawConfigSolvedImpact = Service.ConfigSolvedImpact;
            }
            _configSolvedImpact = RawConfigSolvedImpact;
            if (_configSolvedImpact == StartDependencyImpact.Unknown || (_configSolvedImpact & StartDependencyImpact.IsTryOnly) != 0)
            {
                _configSolvedImpact = StartDependencyImpact.Minimal;
            }

            if (ConfigOriginalStatus == ConfigurationStatus.Disabled)
            {
                _configDisabledReason = PluginDisabledReason.Config;
            }
            else if (p.HasError)
            {
                _configDisabledReason = PluginDisabledReason.PluginInfoHasError;
            }
            else if (Service != null)
            {
                if (Service.Disabled)
                {
                    _configDisabledReason = PluginDisabledReason.ServiceIsDisabled;
                }
                else if (Service.Family.RunningPlugin != null)
                {
                    _configDisabledReason = PluginDisabledReason.AnotherRunningPluginExistsInFamilyByConfig;
                }
            }
            // Immediately check for Runnable references to Disabled Services: this disables us.
            if (!Disabled)
            {
                foreach (var sRef in PluginInfo.ServiceReferences)
                {
                    if (sRef.Requirement >= DependencyRequirement.Runnable)
                    {
                        // If the required service is already disabled, we immediately disable this plugin.
                        if (sRef.Reference.HasError && !Disabled)
                        {
                            _configDisabledReason = PluginDisabledReason.RunnableReferenceServiceIsOnError;
                            break;
                        }
                        ServiceData sr = _solver.FindExistingService(sRef.Reference.ServiceFullName);
                        if (sr.Disabled && !Disabled)
                        {
                            _configDisabledReason = PluginDisabledReason.RunnableReferenceIsDisabled;
                            break;
                        }
                    }
                }
            }
            if (Service != null)
            {
                Service.AddPlugin(this);
            }
            if (!Disabled)
            {
                // If the plugin is not yet disabled, we register it:
                // whenever the referenced service is disabled (or stopped during dynamic resolution), this
                // will disable (or stop) the plugin according to its ConfigSolvedImpact.
                foreach (var sRef in PluginInfo.ServiceReferences)
                {
                    _solver.FindExistingService(sRef.Reference.ServiceFullName).RegisterPluginReference(this, sRef.Requirement);
                }
                if (Service != null && ConfigOriginalStatus == ConfigurationStatus.Running)
                {
                    Service.Family.SetRunningPlugin(this);
                }
            }
        }
예제 #4
0
        internal PluginData( IConfigurationSolver solver, IPluginInfo p, ServiceData service, ConfigurationStatus pluginStatus, StartDependencyImpact impact = StartDependencyImpact.Unknown )
        {
            _solver = solver;
            PluginInfo = p;
            Service = service;
            ConfigOriginalStatus = pluginStatus;
            switch( pluginStatus )
            {
                case ConfigurationStatus.Disabled: _configSolvedStatus = SolvedConfigurationStatus.Disabled; break;
                case ConfigurationStatus.Running: _configSolvedStatus = SolvedConfigurationStatus.Running; break;
                default: _configSolvedStatus = SolvedConfigurationStatus.Runnable; break;
            }
            _configSolvedStatusReason = PluginRunningRequirementReason.Config;

            RawConfigSolvedImpact = ConfigOriginalImpact = impact;
            if( RawConfigSolvedImpact == StartDependencyImpact.Unknown && Service != null )
            {
                RawConfigSolvedImpact = Service.ConfigSolvedImpact;
            }
            _configSolvedImpact = RawConfigSolvedImpact;
            if( _configSolvedImpact == StartDependencyImpact.Unknown || (_configSolvedImpact & StartDependencyImpact.IsTryOnly) != 0 )
            {
                _configSolvedImpact = StartDependencyImpact.Minimal;
            }

            if( ConfigOriginalStatus == ConfigurationStatus.Disabled )
            {
                _configDisabledReason = PluginDisabledReason.Config;
            }
            else if( p.HasError )
            {
                _configDisabledReason = PluginDisabledReason.PluginInfoHasError;
            }
            else if( Service != null )
            {
                if( Service.Disabled )
                {
                    _configDisabledReason = PluginDisabledReason.ServiceIsDisabled;
                }
                else if( Service.Family.RunningPlugin != null )
                {
                    _configDisabledReason = PluginDisabledReason.AnotherRunningPluginExistsInFamilyByConfig;
                }
            }
            // Immediately check for Runnable references to Disabled Services: this disables us.
            if( !Disabled )
            {
                foreach( var sRef in PluginInfo.ServiceReferences )
                {
                    if( sRef.Requirement >= DependencyRequirement.Runnable )
                    {
                        // If the required service is already disabled, we immediately disable this plugin.
                        if( sRef.Reference.HasError && !Disabled )
                        {
                            _configDisabledReason = PluginDisabledReason.RunnableReferenceServiceIsOnError;
                            break;
                        }
                        ServiceData sr = _solver.FindExistingService( sRef.Reference.ServiceFullName );
                        if( sr.Disabled && !Disabled )
                        {
                            _configDisabledReason = PluginDisabledReason.RunnableReferenceIsDisabled;
                            break;
                        }
                    }
                }
            }
            if( Service != null ) Service.AddPlugin( this );
            if( !Disabled  )
            {
                // If the plugin is not yet disabled, we register it:
                // whenever the referenced service is disabled (or stopped during dynamic resolution), this
                // will disable (or stop) the plugin according to its ConfigSolvedImpact.
                foreach( var sRef in PluginInfo.ServiceReferences )
                {
                    _solver.FindExistingService( sRef.Reference.ServiceFullName ).RegisterPluginReference( this, sRef.Requirement );
                }
                if( Service != null && ConfigOriginalStatus == ConfigurationStatus.Running )
                {
                    Service.Family.SetRunningPlugin( this );
                }
            }
        }
예제 #5
0
 internal void SetDisabled( PluginDisabledReason r )
 {
     Debug.Assert( r != PluginDisabledReason.None );
     Debug.Assert( _configDisabledReason == PluginDisabledReason.None );
     _configDisabledReason = r;
     if( Service != null ) Service.OnPluginDisabled( this );
 }