Example #1
0
        public IEnumerable<ServiceData> GetIncludedServices( StartDependencyImpact impact, bool forRunnableStatus )
        {
            if( _runningIncludedServices == null )
            {
                var running = Service != null ? new HashSet<ServiceData>( Service.InheritedServicesWithThis ) : new HashSet<ServiceData>();
                foreach( var sRef in PluginInfo.ServiceReferences )
                {
                    if( sRef.Requirement == DependencyRequirement.Running ) running.Add( _solver.FindExistingService( sRef.Reference.ServiceFullName ) );
                }
                _runningIncludedServices = running.ToReadOnlyList();
                bool newRunnableAdded = false;
                foreach( var sRef in PluginInfo.ServiceReferences )
                {
                    if( sRef.Requirement == DependencyRequirement.Runnable ) newRunnableAdded |= running.Add( _solver.FindExistingService( sRef.Reference.ServiceFullName ) );
                }
                _runnableIncludedServices = newRunnableAdded ? running.ToReadOnlyList() : _runningIncludedServices;
            }

            if( impact == StartDependencyImpact.Minimal ) return forRunnableStatus ? _runnableIncludedServices : _runningIncludedServices;

            if( _inclServices == null ) _inclServices = new IReadOnlyList<ServiceData>[8];
            int iImpact = (int)impact;
            if( impact > StartDependencyImpact.Minimal ) --impact;
            if( forRunnableStatus ) iImpact *= 2;
            --iImpact;

            IReadOnlyList<ServiceData> i = _inclServices[iImpact];
            if( i == null )
            {
                var baseSet = forRunnableStatus ? _runnableIncludedServices : _runningIncludedServices;
                var incl = new HashSet<ServiceData>( baseSet );
                bool newAdded = false;
                foreach( var sRef in PluginInfo.ServiceReferences )
                {
                    ServiceData sr = _solver.FindExistingService( sRef.Reference.ServiceFullName );
                    switch( sRef.Requirement )
                    {
                        case DependencyRequirement.RunnableRecommended:
                            {
                                if( impact >= StartDependencyImpact.StartRecommended )
                                {
                                    newAdded |= incl.Add( sr );
                                }
                                break;
                            }
                        case DependencyRequirement.Runnable:
                            {
                                if( impact == StartDependencyImpact.FullStart )
                                {
                                    newAdded |= incl.Add( sr );
                                }
                                break;
                            }
                        case DependencyRequirement.OptionalRecommended:
                            {
                                if( impact >= StartDependencyImpact.StartRecommended )
                                {
                                    newAdded |= incl.Add( sr );
                                }
                                break;
                            }
                        case DependencyRequirement.Optional:
                            {
                                if( impact == StartDependencyImpact.FullStart )
                                {
                                    newAdded |= incl.Add( sr );
                                }
                                break;
                            }
                    }
                }
                i = _inclServices[iImpact] = newAdded ? incl.ToReadOnlyList() : baseSet;
            }
            return i;
        }
Example #2
0
 public IEnumerable<ServiceData> GetExcludedServices( StartDependencyImpact impact )
 {
     if( _exclServices == null ) _exclServices = new IReadOnlyList<ServiceData>[6];
     IReadOnlyList<ServiceData> e = _exclServices[(int)impact-1];
     if( e == null )
     {
         HashSet<ServiceData> excl = new HashSet<ServiceData>();
         foreach( var sRef in PluginInfo.ServiceReferences )
         {
             ServiceData sr = _solver.FindExistingService( sRef.Reference.ServiceFullName );
             switch( sRef.Requirement )
             {
                 case DependencyRequirement.Running:
                     {
                         excl.UnionWith( sr.DirectExcludedServices );
                         break;
                     }
                 case DependencyRequirement.RunnableRecommended:
                     {
                         if( impact >= StartDependencyImpact.StartRecommended )
                         {
                             excl.UnionWith( sr.DirectExcludedServices );
                         }
                         else if( impact == StartDependencyImpact.FullStop )
                         {
                             excl.Add( sr );
                         }
                         break;
                     }
                 case DependencyRequirement.Runnable:
                     {
                         if( impact == StartDependencyImpact.FullStart )
                         {
                             excl.UnionWith( sr.DirectExcludedServices );
                         }
                         else if( impact <= StartDependencyImpact.StopOptionalAndRunnable )
                         {
                             excl.Add( sr );
                         }
                         break;
                     }
                 case DependencyRequirement.OptionalRecommended:
                     {
                         if( impact >= StartDependencyImpact.StartRecommended )
                         {
                             excl.UnionWith( sr.DirectExcludedServices );
                         }
                         else if( impact == StartDependencyImpact.FullStop )
                         {
                             excl.Add( sr );
                         }
                         break;
                     }
                 case DependencyRequirement.Optional:
                     {
                         if( impact == StartDependencyImpact.FullStart )
                         {
                             excl.UnionWith( sr.DirectExcludedServices );
                         }
                         else if( impact <= StartDependencyImpact.StopOptionalAndRunnable )
                         {
                             excl.Add( sr );
                         }
                         break;
                     }
             }
         }
         e = _exclServices[(int)impact-1] = excl.ToReadOnlyList();
     }
     return e;
 }