Exemple #1
0
 public ServiceReferenceInfo AddServiceReference( ServiceInfo service, DependencyRequirement req )
 {
     var r = new ServiceReferenceInfo( this, service, req );
     _serviceReferences.Add( r );
     return r;
 }
Exemple #2
0
 internal PendingGeneralization(ServiceInfo service, string pendingServiceFullName)
 {
     Service = service;
     PendingServiceFullName = pendingServiceFullName;
 }
Exemple #3
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 #4
0
 internal PendingGeneralization( ServiceInfo service, string pendingServiceFullName )
 {
     Service = service;
     PendingServiceFullName = pendingServiceFullName;
 }
Exemple #5
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 );
            }
        }
        public void InvalidCommonReferences2()
        {
            #region graph
            /*
            *                  +--------+                            +--------+
            *      +-----------|Service1+                            |Service2|---------------+                  +---------------+
            *      |           |Running |                            |Running |               |                  |AnotherBlocking+
            *      |           +---+----+                            +---+----+               |                  |    Runnable   |
            *      |               |                                      |                   |                  +-------+-------+
            *      |               |                                      |                   |                          |
            *      |               |                                      |                   |                          |
            *  +---+-----+         |                                      |                   |                          |
            *  |Plugin1  |     +---+-----+                            +---+-----+         +---+-----+                    |
            *  |Optional |     |Plugin2  |                            |Plugin3  |         |Plugin4  |            +-------+-------------+
            *  +----+----+     |Optional |                            |Optional |         |Optional |            |DisabledForBlocking  |
            *       |          +---------+                            +---------+         +-----+---+            |     Disabled        |
            *       |                   |                                 |                     |                +---------------------+
            *       |                   |                                 |                     |
            *       |                   |                                 |                     |
            *       |                   |                                 |                     |
            *       |                   |                                 |                     |
             *      |                   |                                 |                     |
            *       |                   |                                 |                     |
            *       |                   |           +--------+            |                     |
            *       |                   |           |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
            YodiiEngine engine = new YodiiEngine( new YodiiEngineHostMock() );
            var disco = MockInfoFactory.CreateGraph005b();
            var anotherBlocking = new ServiceInfo( "AnotherBlocking", disco.DefaultAssembly );
            var disabledForBlocking = new PluginInfo( "DisabledForBlocking", disco.DefaultAssembly );
            disabledForBlocking.Service = anotherBlocking;
            disco.ServiceInfos.Add( anotherBlocking );
            disco.PluginInfos.Add( disabledForBlocking );
            engine.SetDiscoveredInfo( disco );

            IConfigurationLayer cl = engine.Configuration.Layers.Create();
            cl.Items.Add( "Service1", ConfigurationStatus.Running );
            cl.Items.Add( "Service2", ConfigurationStatus.Running );
            cl.Items.Add( "AnotherBlocking", ConfigurationStatus.Runnable );
            cl.Items.Add( "DisabledForBlocking", ConfigurationStatus.Disabled );

            engine.FullStaticResolutionOnly( res =>
               {
                   res.CheckAllBlockingServicesAre( "Service1 | Service2, AnotherBlocking" );
                   res.CheckNoBlockingPlugins();
               } );
        }