Exemple #1
0
 internal PendingServiceReference(PluginInfo plugin, string pendingServiceFullName, DependencyRequirement requirement)
 {
     Plugin = plugin;
     PendingServiceFullName = pendingServiceFullName;
     Requirement            = requirement;
 }
Exemple #2
0
 internal PendingPluginService(PluginInfo plugin, string pendingServiceFullName)
 {
     Plugin = plugin;
     PendingServiceFullName = pendingServiceFullName;
 }
Exemple #3
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 #4
0
 internal PendingServiceReference( PluginInfo plugin, string pendingServiceFullName, DependencyRequirement requirement )
 {
     Plugin = plugin;
     PendingServiceFullName = pendingServiceFullName;
     Requirement = requirement;
 }
Exemple #5
0
 internal PendingPluginService( PluginInfo plugin, string pendingServiceFullName )
 {
     Plugin = plugin;
     PendingServiceFullName = pendingServiceFullName;
 }
Exemple #6
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 ) );
                }
            }
        }
        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();
               } );
        }