Exemple #1
0
 private static void ReadPlugins(XmlReader r, DiscoveredInfo d,
                                 CKSortedArrayKeyList <ServiceInfo, string> loadedServices,
                                 CKSortedArrayKeyList <PluginInfo, string> loadedPlugins,
                                 List <PendingPluginService> pendingPluginServices,
                                 List <PendingServiceReference> pendingServiceReferences)
 {
     while (r.Read())
     {
         if (r.IsStartElement() && r.Name == "Plugin")
         {
             ReadPlugin(r.ReadSubtree(), d, loadedServices, loadedPlugins, pendingPluginServices, pendingServiceReferences);
         }
     }
 }
        public static DiscoveredInfo CreateGraph001()
        {
            /**
             *                  +--------+                              +--------+
             *      +---------->|ServiceA+-------+   *----------------->|ServiceB|
             *      |           |        |       |   | Need Running     |        |
             *      |           +---+----+       |   |                  +---+----+
             *      |               |            |   |                      |
             *      |               |            |   |                      |
             *      |               |            |   |                      |
             *  +---+-----+         |        +---+---*-+                    |
             *  |ServiceAx|     +---+-----+  |PluginA-2|                +---+-----+
             *  |         |     |PluginA-1|  |         |                |PluginB-1|
             *  +----+----+     |         |  +---------+                |         |
             *       |          +---------+                             +---------+
             *       |
             *  +----+-----+
             *  |PluginAx-1|
             *  |          |
             *  +----------+
             */

            var d = new DiscoveredInfo();

            d.ServiceInfos.Add( new ServiceInfo( "ServiceA", d.DefaultAssembly ) );
            d.ServiceInfos.Add( new ServiceInfo( "ServiceB", d.DefaultAssembly ) );
            d.ServiceInfos.Add( new ServiceInfo( "ServiceAx", d.DefaultAssembly ) );
            d.FindService( "ServiceAx" ).Generalization = d.FindService( "ServiceA" );

            d.PluginInfos.Add( new PluginInfo( "PluginA-1", d.DefaultAssembly ) );
            d.PluginInfos.Add( new PluginInfo( "PluginA-2", d.DefaultAssembly ) );
            d.PluginInfos.Add( new PluginInfo( "PluginAx-1", d.DefaultAssembly ) );
            d.PluginInfos.Add( new PluginInfo( "PluginB-1", d.DefaultAssembly ) );

            d.FindPlugin( "PluginA-1" ).Service = d.FindService( "ServiceA" );
            d.FindPlugin( "PluginA-2" ).Service = d.FindService( "ServiceA" );
            d.FindPlugin( "PluginAx-1" ).Service = d.FindService( "ServiceAx" );
            d.FindPlugin( "PluginB-1" ).Service = d.FindService( "ServiceB" );

            d.FindPlugin( "PluginA-2" ).AddServiceReference( d.FindService( "ServiceB" ), DependencyRequirement.Running );

            return d;
        }
Exemple #3
0
        public static YodiiEngine CreateEngineFromXml(XmlReader r)
        {
            YodiiEngine    e = new YodiiEngine(new YodiiEngineHostMock());
            DiscoveredInfo d = new DiscoveredInfo();

            // Used to index reference links between plugins and services.
            List <PendingGeneralization>   pendingGeneralizations   = new List <PendingGeneralization>();
            List <PendingPluginService>    pendingPluginServices    = new List <PendingPluginService>();
            List <PendingServiceReference> pendingServiceReferences = new List <PendingServiceReference>();

            CKSortedArrayKeyList <PluginInfo, string>  loadedPlugins;
            CKSortedArrayKeyList <ServiceInfo, string> loadedServices;

            loadedServices = new CKSortedArrayKeyList <ServiceInfo, string>(s => s.ServiceFullName, false);
            loadedPlugins  = new CKSortedArrayKeyList <PluginInfo, string>(p => p.PluginFullName, false);

            while (r.Read())
            {
                // Load services
                if (r.IsStartElement() && r.Name == "Services")
                {
                    ReadServices(r.ReadSubtree(), d, loadedServices, loadedPlugins, pendingGeneralizations, pendingPluginServices, pendingServiceReferences);
                }

                // Load plugins
                if (r.IsStartElement() && r.Name == "Plugins")
                {
                    ReadPlugins(r.ReadSubtree(), d, loadedServices, loadedPlugins, pendingPluginServices, pendingServiceReferences);
                }

                // Read configuration manager
                if (r.IsStartElement() && r.Name == "Configuration")
                {
                    ReadConfigurationManager(e.Configuration, r.ReadSubtree());
                }
            }

            e.SetDiscoveredInfo(d);

            return(e);
        }
Exemple #4
0
        public static YodiiEngine CreateEngineFromXml( XmlReader r )
        {
            YodiiEngine e = new YodiiEngine( new YodiiEngineHostMock() );
            DiscoveredInfo d = new DiscoveredInfo();

            // Used to index reference links between plugins and services.
            List<PendingGeneralization> pendingGeneralizations = new List<PendingGeneralization>();
            List<PendingPluginService> pendingPluginServices = new List<PendingPluginService>();
            List<PendingServiceReference> pendingServiceReferences = new List<PendingServiceReference>();

            CKSortedArrayKeyList<PluginInfo, string> loadedPlugins;
            CKSortedArrayKeyList<ServiceInfo, string> loadedServices;
            loadedServices = new CKSortedArrayKeyList<ServiceInfo, string>( s => s.ServiceFullName, false );
            loadedPlugins = new CKSortedArrayKeyList<PluginInfo, string>( p => p.PluginFullName, false );

            while( r.Read() )
            {
                // Load services
                if( r.IsStartElement() && r.Name == "Services" )
                {
                    ReadServices( r.ReadSubtree(), d, loadedServices, loadedPlugins, pendingGeneralizations, pendingPluginServices, pendingServiceReferences );
                }

                // Load plugins
                if( r.IsStartElement() && r.Name == "Plugins" )
                {
                    ReadPlugins( r.ReadSubtree(), d, loadedServices, loadedPlugins, pendingPluginServices, pendingServiceReferences );
                }

                // Read configuration manager
                if( r.IsStartElement() && r.Name == "Configuration" )
                {
                    ReadConfigurationManager( e.Configuration, r.ReadSubtree() );
                }
            }

            e.SetDiscoveredInfo( d );

            return e;
        }
Exemple #5
0
        private static void ReadPlugin(XmlReader r, DiscoveredInfo d,
                                       CKSortedArrayKeyList <ServiceInfo, string> loadedServices,
                                       CKSortedArrayKeyList <PluginInfo, string> loadedPlugins,
                                       List <PendingPluginService> pendingPluginServices,
                                       List <PendingServiceReference> pendingServiceReferences
                                       )
        {
            r.Read();

            string pluginFullName  = String.Empty;
            string serviceFullName = null;

            List <Tuple <string, DependencyRequirement> > references = new List <Tuple <string, DependencyRequirement> >();

            while (r.Read())
            {
                if (r.IsStartElement() && !r.IsEmptyElement)
                {
                    switch (r.Name)
                    {
                    case "FullName":
                        if (r.Read())
                        {
                            pluginFullName = r.Value;
                        }
                        break;

                    case "Service":
                        if (r.Read())
                        {
                            serviceFullName = r.Value;
                        }
                        break;

                    case "ServiceReferences":
                        while (r.Read())
                        {
                            if (r.IsStartElement() && r.Name == "ServiceReference")
                            {
                                string serviceFullName2 = r.GetAttribute("Service");
                                if (!String.IsNullOrEmpty(serviceFullName2))
                                {
                                    DependencyRequirement requirement = (DependencyRequirement)Enum.Parse(typeof(DependencyRequirement), r.GetAttribute("Requirement"));

                                    references.Add(Tuple.Create(serviceFullName2, requirement));
                                }
                            }
                        }
                        break;
                    }
                }
            }


            PluginInfo p = new PluginInfo(pluginFullName, d.DefaultAssembly);

            d.PluginInfos.Add(p);
            loadedPlugins.Add(p);

            if (!String.IsNullOrEmpty(serviceFullName))
            {
                if (loadedServices.Contains(serviceFullName))
                {
                    var service = loadedServices.GetByKey(serviceFullName);
                    p.Service = service;
                }
                else
                {
                    pendingPluginServices.Add(new PendingPluginService(p, serviceFullName));
                }
            }

            foreach (var t in references)
            {
                if (loadedServices.Contains(t.Item1))
                {
                    p.AddServiceReference(loadedServices.GetByKey(t.Item1), t.Item2);
                }
                else
                {
                    pendingServiceReferences.Add(new PendingServiceReference(p, t.Item1, t.Item2));
                }
            }
        }
Exemple #6
0
        private static void ReadService(XmlReader r, DiscoveredInfo d,
                                        CKSortedArrayKeyList <ServiceInfo, string> loadedServices,
                                        CKSortedArrayKeyList <PluginInfo, string> loadedPlugins,
                                        List <PendingGeneralization> pendingGeneralizations,
                                        List <PendingPluginService> pendingPluginServices,
                                        List <PendingServiceReference> pendingServiceReferences
                                        )
        {
            r.Read();
            string serviceFullName = r.GetAttribute("FullName");

            Debug.Assert(serviceFullName != null, "FullName attribute was found in Service XML element.");

            var s = new ServiceInfo(serviceFullName, d.DefaultAssembly);

            d.ServiceInfos.Add(s);
            loadedServices.Add(s);

            ServiceInfo generalization = null;

            while (r.Read())
            {
                if (r.IsStartElement() && !r.IsEmptyElement)
                {
                    if (r.Name == "Generalization")
                    {
                        if (r.Read())
                        {
                            string generalizationName = r.Value;
                            if (!String.IsNullOrEmpty(generalizationName))
                            {
                                if (loadedServices.Contains(generalizationName))
                                {
                                    generalization   = loadedServices.GetByKey(generalizationName);
                                    s.Generalization = generalization;
                                }
                                else
                                {
                                    pendingGeneralizations.Add(new PendingGeneralization(s, generalizationName));
                                }
                            }
                        }
                    }
                }
            }

            // Fix pending references of this service
            foreach (var pg in pendingGeneralizations.Where(x => x.PendingServiceFullName == serviceFullName).ToList())
            {
                pg.Service.Generalization = s;
                pendingGeneralizations.Remove(pg);
            }

            foreach (var pps in pendingPluginServices.Where(x => x.PendingServiceFullName == serviceFullName).ToList())
            {
                pps.Plugin.Service = s;
                pendingPluginServices.Remove(pps);
            }

            foreach (var psr in pendingServiceReferences.Where(x => x.PendingServiceFullName == serviceFullName).ToList())
            {
                psr.Plugin.AddServiceReference(s, psr.Requirement);
                pendingServiceReferences.Remove(psr);
            }
        }
Exemple #7
0
 private static void ReadServices( XmlReader r, DiscoveredInfo d,
     CKSortedArrayKeyList<ServiceInfo, string> loadedServices,
     CKSortedArrayKeyList<PluginInfo, string> loadedPlugins,
     List<PendingGeneralization> pendingGeneralizations,
     List<PendingPluginService> pendingPluginServices,
     List<PendingServiceReference> pendingServiceReferences
     )
 {
     while( r.Read() )
     {
         if( r.IsStartElement() && r.Name == "Service" )
         {
             ReadService( r.ReadSubtree(), d, loadedServices, loadedPlugins, pendingGeneralizations, pendingPluginServices, pendingServiceReferences );
         }
     }
 }
Exemple #8
0
        private static void ReadService( XmlReader r, DiscoveredInfo d,
            CKSortedArrayKeyList<ServiceInfo, string> loadedServices,
            CKSortedArrayKeyList<PluginInfo, string> loadedPlugins,
            List<PendingGeneralization> pendingGeneralizations,
            List<PendingPluginService> pendingPluginServices,
            List<PendingServiceReference> pendingServiceReferences
            )
        {
            r.Read();
            string serviceFullName = r.GetAttribute( "FullName" );
            Debug.Assert( serviceFullName != null, "FullName attribute was found in Service XML element." );

            var s = new ServiceInfo( serviceFullName, d.DefaultAssembly );
            d.ServiceInfos.Add( s );
            loadedServices.Add( s );

            ServiceInfo generalization = null;

            while( r.Read() )
            {
                if( r.IsStartElement() && !r.IsEmptyElement )
                {
                    if( r.Name == "Generalization" )
                    {
                        if( r.Read() )
                        {
                            string generalizationName = r.Value;
                            if( !String.IsNullOrEmpty( generalizationName ) )
                            {
                                if( loadedServices.Contains( generalizationName ) )
                                {
                                    generalization = loadedServices.GetByKey( generalizationName );
                                    s.Generalization = generalization;
                                }
                                else
                                {
                                    pendingGeneralizations.Add( new PendingGeneralization( s, generalizationName ) );
                                }
                            }
                        }
                    }
                }
            }

            // Fix pending references of this service
            foreach( var pg in pendingGeneralizations.Where( x => x.PendingServiceFullName == serviceFullName ).ToList() )
            {
                pg.Service.Generalization = s;
                pendingGeneralizations.Remove( pg );
            }

            foreach( var pps in pendingPluginServices.Where( x => x.PendingServiceFullName == serviceFullName ).ToList() )
            {
                pps.Plugin.Service = s;
                pendingPluginServices.Remove( pps );
            }

            foreach( var psr in pendingServiceReferences.Where( x => x.PendingServiceFullName == serviceFullName ).ToList() )
            {
                psr.Plugin.AddServiceReference( s, psr.Requirement );
                pendingServiceReferences.Remove( psr );
            }
        }
Exemple #9
0
        private static void ReadPlugin( XmlReader r, DiscoveredInfo d,
            CKSortedArrayKeyList<ServiceInfo, string> loadedServices,
            CKSortedArrayKeyList<PluginInfo, string> loadedPlugins,
            List<PendingPluginService> pendingPluginServices,
            List<PendingServiceReference> pendingServiceReferences
            )
        {
            r.Read();

            string pluginFullName = String.Empty;
            string serviceFullName = null;

            List<Tuple<string,DependencyRequirement>> references = new List<Tuple<string, DependencyRequirement>>();

            while( r.Read() )
            {
                if( r.IsStartElement() && !r.IsEmptyElement )
                {
                    switch( r.Name )
                    {
                        case "FullName":
                            if( r.Read() )
                            {
                                pluginFullName = r.Value;
                            }
                            break;
                        case "Service":
                            if( r.Read() )
                            {
                                serviceFullName = r.Value;
                            }
                            break;
                        case "ServiceReferences":
                            while( r.Read() )
                            {
                                if( r.IsStartElement() && r.Name == "ServiceReference" )
                                {
                                    string serviceFullName2 = r.GetAttribute( "Service" );
                                    if( !String.IsNullOrEmpty( serviceFullName2 ) )
                                    {
                                        DependencyRequirement requirement = (DependencyRequirement)Enum.Parse( typeof( DependencyRequirement ), r.GetAttribute( "Requirement" ) );

                                        references.Add( Tuple.Create( serviceFullName2, requirement ) );

                                    }
                                }
                            }
                            break;
                    }
                }
            }

            PluginInfo p = new PluginInfo( pluginFullName, d.DefaultAssembly );
            d.PluginInfos.Add( p );
            loadedPlugins.Add( p );

            if( !String.IsNullOrEmpty( serviceFullName ) )
            {
                if( loadedServices.Contains( serviceFullName ) )
                {
                    var service = loadedServices.GetByKey( serviceFullName );
                    p.Service = service;
                }
                else
                {
                    pendingPluginServices.Add( new PendingPluginService( p, serviceFullName ) );
                }
            }

            foreach( var t in references )
            {

                if( loadedServices.Contains( t.Item1 ) )
                {
                    p.AddServiceReference( loadedServices.GetByKey( t.Item1 ), t.Item2 );
                }
                else
                {
                    pendingServiceReferences.Add( new PendingServiceReference( p, t.Item1, t.Item2 ) );
                }
            }
        }
        internal static IDiscoveredInfo CreateGraph008()
        {
            DiscoveredInfo d = new DiscoveredInfo();

            d.ServiceInfos.Add( new ServiceInfo( "Service1", d.DefaultAssembly ) );
            d.ServiceInfos.Add( new ServiceInfo( "Service2", d.DefaultAssembly ) );

            d.ServiceInfos.Add( new ServiceInfo( "Service1.1", d.DefaultAssembly ) );
            d.FindService( "Service1.1" ).Generalization = d.FindService( "Service1" );
            d.ServiceInfos.Add( new ServiceInfo( "Service1.2", d.DefaultAssembly ) );
            d.FindService( "Service1.2" ).Generalization = d.FindService( "Service1" );
            d.ServiceInfos.Add( new ServiceInfo( "Service1.3", d.DefaultAssembly ) );
            d.FindService( "Service1.3" ).Generalization = d.FindService( "Service1" );

            d.ServiceInfos.Add( new ServiceInfo( "Service1.1.1", d.DefaultAssembly ) );
            d.FindService( "Service1.1.1" ).Generalization = d.FindService( "Service1.1" );
            d.ServiceInfos.Add( new ServiceInfo( "Service1.1.2", d.DefaultAssembly ) );
            d.FindService( "Service1.1.2" ).Generalization = d.FindService( "Service1.1" );
            d.ServiceInfos.Add( new ServiceInfo( "Service1.1.3", d.DefaultAssembly ) );
            d.FindService( "Service1.1.3" ).Generalization = d.FindService( "Service1.1" );

            d.ServiceInfos.Add( new ServiceInfo( "Service1.2.1", d.DefaultAssembly ) );
            d.FindService( "Service1.2.1" ).Generalization = d.FindService( "Service1.2" );
            d.ServiceInfos.Add( new ServiceInfo( "Service1.2.2", d.DefaultAssembly ) );
            d.FindService( "Service1.2.2" ).Generalization = d.FindService( "Service1.2" );
            d.ServiceInfos.Add( new ServiceInfo( "Service1.2.3", d.DefaultAssembly ) );
            d.FindService( "Service1.2.3" ).Generalization = d.FindService( "Service1.2" );

            d.ServiceInfos.Add( new ServiceInfo( "Service1.3.1", d.DefaultAssembly ) );
            d.FindService( "Service1.3.1" ).Generalization = d.FindService( "Service1.3" );
            d.ServiceInfos.Add( new ServiceInfo( "Service1.3.2", d.DefaultAssembly ) );
            d.FindService( "Service1.3.2" ).Generalization = d.FindService( "Service1.3" );
            d.ServiceInfos.Add( new ServiceInfo( "Service1.3.3", d.DefaultAssembly ) );
            d.FindService( "Service1.3.3" ).Generalization = d.FindService( "Service1.3" );

            d.ServiceInfos.Add( new ServiceInfo( "Service2.1", d.DefaultAssembly ) );
            d.FindService( "Service2.1" ).Generalization = d.FindService( "Service2" );
            d.ServiceInfos.Add( new ServiceInfo( "Service2.2", d.DefaultAssembly ) );
            d.FindService( "Service2.2" ).Generalization = d.FindService( "Service2" );
            d.ServiceInfos.Add( new ServiceInfo( "Service2.3", d.DefaultAssembly ) );
            d.FindService( "Service2.3" ).Generalization = d.FindService( "Service2" );

            d.PluginInfos.Add( new PluginInfo( "Plugin1", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin1" ).Service = d.FindService( "Service2.1" );
            d.PluginInfos.Add( new PluginInfo( "Plugin2", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin2" ).Service = d.FindService( "Service2.1" );

            d.PluginInfos.Add( new PluginInfo( "Plugin3", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin3" ).Service = d.FindService( "Service2.2" );
            d.PluginInfos.Add( new PluginInfo( "Plugin4", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin4" ).Service = d.FindService( "Service2.2" );

            d.PluginInfos.Add( new PluginInfo( "Plugin5", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin5" ).Service = d.FindService( "Service2.3" );
            d.PluginInfos.Add( new PluginInfo( "Plugin6", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin6" ).Service = d.FindService( "Service2.3" );
            d.FindPlugin( "Plugin6" ).AddServiceReference( d.FindService( "Service1.2.3" ), DependencyRequirement.Runnable );

            d.PluginInfos.Add( new PluginInfo( "Plugin7", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin7" ).Service = d.FindService( "Service1.1.1" );
            d.PluginInfos.Add( new PluginInfo( "Plugin8", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin8" ).Service = d.FindService( "Service1.1.1" );

            d.PluginInfos.Add( new PluginInfo( "Plugin9", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin9" ).Service = d.FindService( "Service1.1.2" );
            d.PluginInfos.Add( new PluginInfo( "Plugin10", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin10" ).Service = d.FindService( "Service1.1.2" );

            d.PluginInfos.Add( new PluginInfo( "Plugin11", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin11" ).Service = d.FindService( "Service1.1.3" );
            d.PluginInfos.Add( new PluginInfo( "Plugin12", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin12" ).Service = d.FindService( "Service1.1.3" );

            d.PluginInfos.Add( new PluginInfo( "Plugin13", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin13" ).Service = d.FindService( "Service1.2.1" );
            d.PluginInfos.Add( new PluginInfo( "Plugin14", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin14" ).Service = d.FindService( "Service1.2.1" );

            d.PluginInfos.Add( new PluginInfo( "Plugin15", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin15" ).Service = d.FindService( "Service1.2.2" );
            d.PluginInfos.Add( new PluginInfo( "Plugin16", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin16" ).Service = d.FindService( "Service1.2.2" );

            d.PluginInfos.Add( new PluginInfo( "Plugin17", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin17" ).Service = d.FindService( "Service1.2.3" );
            d.FindPlugin( "Plugin17" ).AddServiceReference( d.FindService( "Service2.2" ), DependencyRequirement.RunnableRecommended );

            d.PluginInfos.Add( new PluginInfo( "Plugin18", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin18" ).Service = d.FindService( "Service1.2.3" );

            d.PluginInfos.Add( new PluginInfo( "Plugin19", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin19" ).Service = d.FindService( "Service1.3.1" );
            d.PluginInfos.Add( new PluginInfo( "Plugin20", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin20" ).Service = d.FindService( "Service1.3.1" );

            d.PluginInfos.Add( new PluginInfo( "Plugin21", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin21" ).Service = d.FindService( "Service1.3.2" );
            d.PluginInfos.Add( new PluginInfo( "Plugin22", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin22" ).Service = d.FindService( "Service1.3.2" );

            d.PluginInfos.Add( new PluginInfo( "Plugin23", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin23" ).Service = d.FindService( "Service1.3.3" );
            d.PluginInfos.Add( new PluginInfo( "Plugin24", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin24" ).Service = d.FindService( "Service1.3.3" );

            return d;
        }
        internal static IDiscoveredInfo CreateGraph007()
        {
            DiscoveredInfo d = new DiscoveredInfo();

            d.ServiceInfos.Add( new ServiceInfo( "Service1", d.DefaultAssembly ) );
            d.ServiceInfos.Add( new ServiceInfo( "Service2", d.DefaultAssembly ) );

            d.ServiceInfos.Add( new ServiceInfo( "Service1.1", d.DefaultAssembly ) );
            d.FindService( "Service1.1" ).Generalization = d.FindService( "Service1" );

            d.ServiceInfos.Add( new ServiceInfo( "Service1.2", d.DefaultAssembly ) );
            d.FindService( "Service1.2" ).Generalization = d.FindService( "Service1" );

            d.ServiceInfos.Add( new ServiceInfo( "Service1.3", d.DefaultAssembly ) );
            d.FindService( "Service1.3" ).Generalization = d.FindService( "Service1" );

            d.ServiceInfos.Add( new ServiceInfo( "Service2.1", d.DefaultAssembly ) );
            d.FindService( "Service2.1" ).Generalization = d.FindService( "Service2" );

            d.ServiceInfos.Add( new ServiceInfo( "Service2.2", d.DefaultAssembly ) );
            d.FindService( "Service2.2" ).Generalization = d.FindService( "Service2" );

            d.PluginInfos.Add( new PluginInfo( "Plugin1", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin1" ).Service = d.FindService( "Service1.1" );
            d.FindPlugin( "Plugin1" ).AddServiceReference( d.FindService("Service2.1"), DependencyRequirement.Runnable );

            d.PluginInfos.Add( new PluginInfo( "Plugin2", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin2" ).Service = d.FindService( "Service1.2" );

            d.PluginInfos.Add( new PluginInfo( "Plugin3", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin3" ).Service = d.FindService( "Service1.3" );

            d.PluginInfos.Add( new PluginInfo( "Plugin4", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin4" ).Service = d.FindService( "Service2.1" );

            d.PluginInfos.Add( new PluginInfo( "Plugin5", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin5" ).Service = d.FindService( "Service2.2" );

            return d;
        }
        internal static IDiscoveredInfo CreateGraph006()
        {
            DiscoveredInfo d = new DiscoveredInfo();

            #region graph
            //See PNG for better viewing
            #endregion

            d.ServiceInfos.Add( new ServiceInfo( "Service1", d.DefaultAssembly ) );
            d.ServiceInfos.Add( new ServiceInfo( "Service2", d.DefaultAssembly ) );
            d.ServiceInfos.Add( new ServiceInfo( "Service3", d.DefaultAssembly ) );

            d.ServiceInfos.Add( new ServiceInfo( "Service3.1", d.DefaultAssembly ) );
            d.FindService( "Service3.1" ).Generalization = d.FindService( "Service3" );
            d.ServiceInfos.Add( new ServiceInfo( "Service3.2", d.DefaultAssembly ) );
            d.FindService( "Service3.2" ).Generalization = d.FindService( "Service3" );
            d.ServiceInfos.Add( new ServiceInfo( "Service3.3", d.DefaultAssembly ) );
            d.FindService( "Service3.3" ).Generalization = d.FindService( "Service3" );

            d.ServiceInfos.Add( new ServiceInfo( "Service4", d.DefaultAssembly ) );

            d.ServiceInfos.Add( new ServiceInfo( "Service4.1", d.DefaultAssembly ) );
            d.FindService( "Service4.1" ).Generalization = d.FindService( "Service4" );
            d.ServiceInfos.Add( new ServiceInfo( "Service4.2", d.DefaultAssembly ) );
            d.FindService( "Service4.2" ).Generalization = d.FindService( "Service4" );

            d.PluginInfos.Add( new PluginInfo( "Plugin1", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin1" ).Service = d.FindService( "Service1" );
            d.FindPlugin( "Plugin1" ).AddServiceReference( d.FindService( "Service4.1" ), DependencyRequirement.Runnable );

            d.PluginInfos.Add( new PluginInfo( "Plugin2", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin2" ).Service = d.FindService( "Service1" );
            d.FindPlugin( "Plugin2" ).AddServiceReference( d.FindService( "Service3.3" ), DependencyRequirement.Runnable );

            d.PluginInfos.Add( new PluginInfo( "Plugin3", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin3" ).Service = d.FindService( "Service2" );
            d.FindPlugin( "Plugin3" ).AddServiceReference( d.FindService( "Service3.2" ), DependencyRequirement.Runnable );

            d.PluginInfos.Add( new PluginInfo( "Plugin4", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin4" ).Service = d.FindService( "Service2" );
            d.FindPlugin( "Plugin4" ).AddServiceReference( d.FindService( "Service3.1" ), DependencyRequirement.Runnable );

            d.PluginInfos.Add( new PluginInfo( "Plugin5", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin5" ).Service = d.FindService( "Service4.2" );

            d.PluginInfos.Add( new PluginInfo( "Plugin6", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin6" ).Service = d.FindService( "Service4.1" );

            d.PluginInfos.Add( new PluginInfo( "Plugin7", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin7" ).Service = d.FindService( "Service3.1" );
            d.FindPlugin( "Plugin7" ).AddServiceReference( d.FindService( "Service4.1" ), DependencyRequirement.Runnable );

            d.PluginInfos.Add( new PluginInfo( "Plugin8", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin8" ).Service = d.FindService( "Service3.3" );
            d.FindPlugin( "Plugin8" ).AddServiceReference( d.FindService( "Service1" ), DependencyRequirement.Runnable );

            d.PluginInfos.Add( new PluginInfo( "Plugin9", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin9" ).Service = d.FindService( "Service3.2" );
            d.FindPlugin( "Plugin9" ).AddServiceReference( d.FindService( "Service4.2" ), DependencyRequirement.Runnable );

            return d;
        }
        internal static IDiscoveredInfo CreateGraph005f()
        {
            #region graph
            /*
            *                  +--------+                            +--------+
            *      +-----------|Service1+                            |Service2|---------------+
            *      |           |Running |                            |Running |               |
            *      |           +---+----+                            +----+---+               |
            *      |               |                                      |                   |
            *      |               |                                      |                   |
            *      |               |                                      |                   |
            *  +---+-----+         |                                      |                   |
            *  |Plugin1  |     +---+-----+                            +---+-----+         +---+-----+
            *  |Optional |     |Plugin2  |                            |Plugin3  |         |Plugin4  +--------------------+
            *  +----+----+     |Optional |------------------------+   |Optional |         |Optional |                    |
            *       |          +---------+                        |   +---------+         +---------+                    |
            *       |                   |                         |       |                                              |
            *       |                   |                         |       |                                              |
            *       |                   |                         |       |                                              |
            *       |                   |                         |       |                                              |
            *       |                   |                         |       |                                              |
             *      |                   |                         |       |                                              |
            *       |                   |                         |       |                                              |
            *       |                   |           +--------+    |       |                                              |
            *       |                   |           |Service3+    |       |                   +--------+                 |
            *       |       +-----------|-----------|Optional|    |       |                   |Service4+                 |
            *       |       |           |           +---+----+    |       |       +-----------|Optional|-------+         |
            *       |       |           |               |         |       |       |           +---+----+       |         |
            *       |       |           |               |         |       |       |                            |         |
            *       |   +---+-------+   |          +----+------+  |       |       |                            |         |
            *       |   |Service3.1 |   |          |Service3.2 |  |       |    +--+--------+             +-----+-----+   |
            *       +-->|Optional   |   |          |Optional   |  +-------|--->|Service4.1 |             |Service4.2 |   |
             *          +-----------+   |          +-----+-----+          |    |Optional   |             |Optional   |<--+
             *              |           |                |                |    +-----------+             +-----+-----+
             *              |           |                |                |        |                           |
             *          +---+-------+   +--------->+-----+-----+          |        |                           |
             *          |Service3.3 |              |Service3.4 |          | +---+-------+              +----+------+
             *          |Optional   |              |Optional   |          +>|Service4.3 |              |Service4.4 |
             *          +--+--------+              +-----------+            |Optional   |              |Optional   |
             *             |                            |                   +--+--------+              +-----------+
             *             |                            |                      |                            |
             *             |                            |                      |                            |
             *          +--+-----+                  +---+----+                 |                            |
             *          |Plugin5 |                  |Plugin6 |              +--+-----+                  +---+----+
             *          |Optional|                  |Optional|              |Plugin7 |                  |Plugin8 |
             *          +--------+                  +--------+              |Optional|                  |Optional|
             *                                                              +--------+                  +--------+
            */
            #endregion

            var d = new DiscoveredInfo();

            d.ServiceInfos.Add( new ServiceInfo( "Service1", d.DefaultAssembly ) );
            d.ServiceInfos.Add( new ServiceInfo( "Service2", d.DefaultAssembly ) );
            d.ServiceInfos.Add( new ServiceInfo( "Service3", d.DefaultAssembly ) );
            d.ServiceInfos.Add( new ServiceInfo( "Service4", d.DefaultAssembly ) );

            d.ServiceInfos.Add( new ServiceInfo( "Service3.1", d.DefaultAssembly ) );
            d.ServiceInfos.Add( new ServiceInfo( "Service3.3", d.DefaultAssembly ) );
            d.FindService( "Service3.1" ).Generalization = d.FindService( "Service3" );
            d.FindService( "Service3.3" ).Generalization = d.FindService( "Service3.1" );

            d.ServiceInfos.Add( new ServiceInfo( "Service3.2", d.DefaultAssembly ) );
            d.ServiceInfos.Add( new ServiceInfo( "Service3.4", d.DefaultAssembly ) );
            d.FindService( "Service3.2" ).Generalization = d.FindService( "Service3" );
            d.FindService( "Service3.4" ).Generalization = d.FindService( "Service3.2" );

            d.ServiceInfos.Add( new ServiceInfo( "Service4.1", d.DefaultAssembly ) );
            d.ServiceInfos.Add( new ServiceInfo( "Service4.3", d.DefaultAssembly ) );
            d.FindService( "Service4.1" ).Generalization = d.FindService( "Service4" );
            d.FindService( "Service4.3" ).Generalization = d.FindService( "Service4.1" );

            d.ServiceInfos.Add( new ServiceInfo( "Service4.2", d.DefaultAssembly ) );
            d.ServiceInfos.Add( new ServiceInfo( "Service4.4", d.DefaultAssembly ) );
            d.FindService( "Service4.2" ).Generalization = d.FindService( "Service4" );
            d.FindService( "Service4.4" ).Generalization = d.FindService( "Service4.2" );

            d.PluginInfos.Add( new PluginInfo( "Plugin1", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin1" ).Service = d.FindService( "Service1" );

            d.PluginInfos.Add( new PluginInfo( "Plugin2", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin2" ).Service = d.FindService( "Service1" );

            d.PluginInfos.Add( new PluginInfo( "Plugin3", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin3" ).Service = d.FindService( "Service2" );

            d.PluginInfos.Add( new PluginInfo( "Plugin4", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin4" ).Service = d.FindService( "Service2" );

            d.PluginInfos.Add( new PluginInfo( "Plugin5", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin5" ).Service = d.FindService( "Service3.3" );

            d.PluginInfos.Add( new PluginInfo( "Plugin6", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin6" ).Service = d.FindService( "Service3.4" );

            d.PluginInfos.Add( new PluginInfo( "Plugin7", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin7" ).Service = d.FindService( "Service4.3" );

            d.PluginInfos.Add( new PluginInfo( "Plugin8", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin8" ).Service = d.FindService( "Service4.4" );

            d.FindPlugin( "Plugin1" ).AddServiceReference( d.FindService( "Service3.1" ), DependencyRequirement.OptionalRecommended);
            d.FindPlugin( "Plugin2" ).AddServiceReference( d.FindService( "Service3.4" ), DependencyRequirement.OptionalRecommended );
            d.FindPlugin( "Plugin2" ).AddServiceReference( d.FindService( "Service4.1" ), DependencyRequirement.OptionalRecommended );

            d.FindPlugin( "Plugin3" ).AddServiceReference( d.FindService( "Service4.3" ), DependencyRequirement.OptionalRecommended );
            d.FindPlugin( "Plugin4" ).AddServiceReference( d.FindService( "Service4.2" ), DependencyRequirement.OptionalRecommended );

            return d;
        }
        internal static IDiscoveredInfo CreateGraph005e()
        {
            DiscoveredInfo d = new DiscoveredInfo();

            #region graph
            /*
            *                  +--------+
            *      +-----------|Service1+
            *      |           |Running |
            *      |           +---+----+
            *      |               |
            *      |               |
            *      |               |
            *  +---+-----+         |
            *  |Plugin1  |     +---+-----+
            *  |Optional |     |Plugin2  |
            *  +----+----+     |Optional |-----------------------+
            *       |          +---------+                       |
            *       |                                            |
            *       |                                            |
            *       |                                            |
            *       |                                            |
            *       |Optional                                    |
             *      |                                            |
            *       |                                            |
             *      |                                            |
            *       |                              +---------+   |
            *       |                              |Service2 |   |
            *       |       +----------------------|Optional |   |
            *       |       |                       +---+----+   |
            *       |       |                          |         |
            *       |       |                          |         |
            *       |   +---+-------+             +----+------+  |
            *       |   |Service2.1 |             |Service2.2 |<-+
            *       +-->|Optional   |             |Optional   |
            *           +-----------+             +-----+-----+
            *               |                           |
            *               |                           |
            *               |                         +--+-----+
            *               |                         |Plugin4 |
            *            +--+-----+                   |Optional|
            *            |Plugin3 |                   +--------+
            *            |Optional|
            *            +--------+
            *
            *
            *
            */
            #endregion

            d.ServiceInfos.Add( new ServiceInfo( "Service1", d.DefaultAssembly ) );
            d.ServiceInfos.Add( new ServiceInfo( "Service2", d.DefaultAssembly ) );

            d.ServiceInfos.Add( new ServiceInfo( "Service2.1", d.DefaultAssembly ) );
            d.FindService( "Service2.1" ).Generalization = d.FindService( "Service2" );

            d.ServiceInfos.Add( new ServiceInfo( "Service2.2", d.DefaultAssembly ) );
            d.FindService( "Service2.2" ).Generalization = d.FindService( "Service2" );

            d.PluginInfos.Add( new PluginInfo( "Plugin1", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin1" ).Service = d.FindService( "Service1" );
            d.FindPlugin( "Plugin1" ).AddServiceReference( d.FindService( "Service2.1" ), DependencyRequirement.Optional );

            d.PluginInfos.Add( new PluginInfo( "Plugin2", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin2" ).Service = d.FindService( "Service1" );
            d.FindPlugin( "Plugin2" ).AddServiceReference( d.FindService( "Service2.2" ), DependencyRequirement.Optional );

            d.PluginInfos.Add( new PluginInfo( "Plugin3", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin3" ).Service = d.FindService( "Service2.1" );
            d.PluginInfos.Add( new PluginInfo( "Plugin4", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin4" ).Service = d.FindService( "Service2.2" );

            return d;
        }
        public static DiscoveredInfo CreateGraph005b()
        {
            #region graph
            /*
            *                  +--------+                            +--------+
            *      +-----------|Service1+                            |Service2|---------------+
            *      |           |Running |                            |Running |               |
            *      |           +---+----+                            +---+----+               |
            *      |               |                                      |                   |
            *      |               |                                      |                   |
            *      |               |                                      |                   |
            *  +---+-----+         |                                      |                   |
            *  |Plugin1  |     +---+-----+                            +---+-----+         +---+-----+
            *  |Optional |     |Plugin2  |                            |Plugin3  |         |Plugin4  |
            *  +----+----+     |Optional |                            |Optional |         |Optional |
            *       |          +---------+                            +---------+         +-----+---+
            *       |                   |                                 |                     |
            *       |                   |                                 |                     |
            *       |                   |                                 |                     |
            *       |                   |                                 |                     |
            *       |                   |                                 |                     |
             *      |                   |                                 |                     |
            *       |                   |                                 |                     |
            *       |                   |           +--------+            |                     |
            *       |                   |           |Service3+            |                     |
            *       |       +-----------|-----------|Optional|------------|------+--------------+-----------+
            *       |       |           |           +---+----+            |      |              |           |
            *       |       |           |               |                 |      |              |           |
            *       |       |           |               |                 |      |              |           |
            *       |   +---+-------+   +-------->+-----+-----+           |  +---+-------+      |       +---+-------+
            *       |   |Service3.1 |             |Service3.2 |           |  |Service3.3 |      |       |Service3.4 |
            *       +-->|Optional   |             |Optional   |           +->|Optional   |      +------>|Optional   |
             *          +-----------+             +-----------+              +-----------+              +-----------+
             *          |           |             |           |              |           |              |           |
             *          |           |             |           |              |           |              |           |
             *          |           |             |           |              |           |              |           |
             *      +---+-----+ +---+-----+   +---+-----+ +---+-----+    +---+-----+ +---+-----+    +---+-----+ +---+-----+
             *      |Plugin5  | |Plugin6  |   |Plugin7  | |Plugin8  |    |Plugin9  | |Plugin10 |    |Plugin11 | |Plugin12 |
             *      |Optional | |Optional |   |Optional | |Optional |    |Optional | |Optional |    |Optional | |Optional |
             *      +---------+ +---------+   +---------+ +---------+    +---------+ +---------+    +---------+ +---------+
             *
            */
            #endregion

            var d = new DiscoveredInfo();

            d.ServiceInfos.Add( new ServiceInfo( "Service1", d.DefaultAssembly ) );
            d.ServiceInfos.Add( new ServiceInfo( "Service2", d.DefaultAssembly ) );
            d.ServiceInfos.Add( new ServiceInfo( "Service3", d.DefaultAssembly ) );

            d.ServiceInfos.Add( new ServiceInfo( "Service3.1", d.DefaultAssembly ) );
            d.FindService( "Service3.1" ).Generalization = d.FindService( "Service3" );

            d.ServiceInfos.Add( new ServiceInfo( "Service3.2", d.DefaultAssembly ) );
            d.FindService( "Service3.2" ).Generalization = d.FindService( "Service3" );

            d.ServiceInfos.Add( new ServiceInfo( "Service3.3", d.DefaultAssembly ) );
            d.FindService( "Service3.3" ).Generalization = d.FindService( "Service3" );

            d.ServiceInfos.Add( new ServiceInfo( "Service3.4", d.DefaultAssembly ) );
            d.FindService( "Service3.4" ).Generalization = d.FindService( "Service3" );

            d.PluginInfos.Add( new PluginInfo( "Plugin1", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin1" ).Service = d.FindService( "Service1" );

            d.PluginInfos.Add( new PluginInfo( "Plugin2", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin2" ).Service = d.FindService( "Service1" );

            d.PluginInfos.Add( new PluginInfo( "Plugin3", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin3" ).Service = d.FindService( "Service2" );

            d.PluginInfos.Add( new PluginInfo( "Plugin4", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin4" ).Service = d.FindService( "Service2" );

            d.PluginInfos.Add( new PluginInfo( "Plugin5", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin5" ).Service = d.FindService( "Service3.1" );

            d.PluginInfos.Add( new PluginInfo( "Plugin6", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin6" ).Service = d.FindService( "Service3.1" );

            d.PluginInfos.Add( new PluginInfo( "Plugin7", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin7" ).Service = d.FindService( "Service3.2" );

            d.PluginInfos.Add( new PluginInfo( "Plugin8", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin8" ).Service = d.FindService( "Service3.2" );

            d.PluginInfos.Add( new PluginInfo( "Plugin9", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin9" ).Service = d.FindService( "Service3.3" );

            d.PluginInfos.Add( new PluginInfo( "Plugin10", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin10" ).Service = d.FindService( "Service3.3" );

            d.PluginInfos.Add( new PluginInfo( "Plugin11", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin11" ).Service = d.FindService( "Service3.4" );

            d.PluginInfos.Add( new PluginInfo( "Plugin12", d.DefaultAssembly ) );
            d.FindPlugin( "Plugin12" ).Service = d.FindService( "Service3.4" );

            d.FindPlugin( "Plugin1" ).AddServiceReference( d.FindService( "Service3.1" ), DependencyRequirement.Running );
            d.FindPlugin( "Plugin2" ).AddServiceReference( d.FindService( "Service3.2" ), DependencyRequirement.Running );

            d.FindPlugin( "Plugin3" ).AddServiceReference( d.FindService( "Service3.3" ), DependencyRequirement.Running );
            d.FindPlugin( "Plugin4" ).AddServiceReference( d.FindService( "Service3.4" ), DependencyRequirement.Running );

            return d;
        }
        public static DiscoveredInfo CreateGraph004()
        {
            /**
             *  +--------+
             *  |ServiceA+ ------+
             *  |        |       |
             *  +---+----+       |
             *      |            |
             *      |            |
             *      |            |
             *      |         +---+------+
             *  +---+------+  |ServiceAx2|
             *  |ServiceAx1|  |          |
             *  |          |  +----------+
             *  +----------+      |
             *      |             |
             *      |             |
             *      |             |
             *      |          +---+-------+
             *  +---+-------+  |PluginAx2-1|
             *  |PluginAx1-1|  |           |
             *  |           |  +-----------+
             *  +-----------+
             */

            var d = new DiscoveredInfo();

            d.ServiceInfos.Add( new ServiceInfo( "ServiceA", d.DefaultAssembly ) );
            d.ServiceInfos.Add( new ServiceInfo( "ServiceAx1", d.DefaultAssembly ) );
            d.ServiceInfos.Add( new ServiceInfo( "ServiceAx2", d.DefaultAssembly ) );
            d.FindService( "ServiceAx1" ).Generalization = d.FindService( "ServiceA" );
            d.FindService( "ServiceAx2" ).Generalization = d.FindService( "ServiceA" );

            d.PluginInfos.Add( new PluginInfo( "PluginAx1-1", d.DefaultAssembly ) );
            d.PluginInfos.Add( new PluginInfo( "PluginAx2-2", d.DefaultAssembly ) );

            d.FindPlugin( "PluginAx1-1" ).Service = d.FindService( "ServiceAx1" );
            d.FindPlugin( "PluginAx2-2" ).Service = d.FindService( "ServiceAx2" );

            return d;
        }