Esempio n. 1
0
        private static void SerializeConfigurationManager(PersistedLabState s, XmlWriter w)
        {
            foreach (var layer in s.ConfigurationLayers)
            {
                w.WriteStartElement("ConfigurationLayer");

                w.WriteStartAttribute("Name");
                w.WriteValue(layer.LayerName);
                w.WriteEndAttribute();

                foreach (var item in layer.Items)
                {
                    w.WriteStartElement("ConfigurationItem");

                    w.WriteStartAttribute("ServiceOrPluginId");
                    w.WriteValue(item.ServiceOrPluginId);
                    w.WriteEndAttribute();

                    w.WriteStartAttribute("Status");
                    w.WriteValue(item.Status.ToString());
                    w.WriteEndAttribute();

                    w.WriteStartAttribute("Reason");
                    w.WriteValue(item.StatusReason);
                    w.WriteEndAttribute();

                    w.WriteEndElement();
                }

                w.WriteEndElement();
            }
        }
Esempio n. 2
0
        private static PersistedLabState CreatePersistentObject(LabStateManager runningState)
        {
            PersistedLabState persistedState = new PersistedLabState();

            // Persist layer
            foreach (IConfigurationLayer l in runningState.Engine.Configuration.Layers)
            {
                PersistedConfigurationLayer persistedLayer = new PersistedConfigurationLayer();
                persistedState.ConfigurationLayers.Add(persistedLayer);

                persistedLayer.LayerName = l.LayerName;
                foreach (IConfigurationItem i in l.Items)
                {
                    PersistedConfigurationItem persistedItem = new PersistedConfigurationItem();
                    persistedItem.ServiceOrPluginId = i.ServiceOrPluginFullName;
                    persistedItem.Status            = i.Status;
                    persistedItem.StatusReason      = i.StatusReason;

                    persistedLayer.Items.Add(persistedItem);
                }
            }

            // Persist service and plugins -- We already have the mocks, so we can use them.
            foreach (ServiceInfo s in runningState.ServiceInfos)
            {
                persistedState.Services.Add(s);
            }
            foreach (PluginInfo p in runningState.PluginInfos)
            {
                persistedState.Plugins.Add(p);
            }

            return(persistedState);
        }
Esempio n. 3
0
        public static void SerializeToXml(LabStateManager state, XmlWriter w)
        {
            PersistedLabState stateToSerialize = CreatePersistentObject(state);

            w.WriteStartElement("Yodii.Lab");

            w.WriteStartElement("Services");
            foreach (ServiceInfo si in state.ServiceInfos)
            {
                w.WriteStartElement("Service");
                SerializeServiceInfoToXmlWriter(si, w);
                w.WriteEndElement();
            }
            w.WriteEndElement();

            w.WriteStartElement("Plugins");
            foreach (PluginInfo pi in state.PluginInfos)
            {
                w.WriteStartElement("Plugin");
                SerializePluginInfoToXmlWriter(pi, w);
                w.WriteEndElement();
            }
            w.WriteEndElement();

            w.WriteStartElement("Configuration");
            SerializeConfigurationManager(stateToSerialize, w);
            w.WriteEndElement();

            w.WriteEndElement();
        }
Esempio n. 4
0
        internal LabXmlDeserializer( LabStateManager state, XmlReader r )
        {
            this.state = state;
            this.r = r;
            deserializedState = new PersistedLabState();
            // Used to index reference links between plugins and services.
            pendingGeneralizations = new List<PendingGeneralization>();
            pendingPluginServices = new List<PendingPluginService>();
            pendingServiceReferences = new List<PendingServiceReference>();

            loadedServices = new CKSortedArrayKeyList<ServiceInfo, string>( s => s.ServiceFullName, false );
            loadedPlugins = new CKSortedArrayKeyList<PluginInfo, string>( p => p.PluginFullName, false );
        }
Esempio n. 5
0
        internal LabXmlDeserializer(LabStateManager state, XmlReader r)
        {
            this.state        = state;
            this.r            = r;
            deserializedState = new PersistedLabState();
            // Used to index reference links between plugins and services.
            pendingGeneralizations   = new List <PendingGeneralization>();
            pendingPluginServices    = new List <PendingPluginService>();
            pendingServiceReferences = new List <PendingServiceReference>();

            loadedServices = new CKSortedArrayKeyList <ServiceInfo, string>(s => s.ServiceFullName, false);
            loadedPlugins  = new CKSortedArrayKeyList <PluginInfo, string>(p => p.PluginFullName, false);
        }
Esempio n. 6
0
        private static void SerializeConfigurationManager( PersistedLabState s, XmlWriter w )
        {
            foreach( var layer in s.ConfigurationLayers )
            {
                w.WriteStartElement( "ConfigurationLayer" );

                w.WriteStartAttribute( "Name" );
                w.WriteValue( layer.LayerName );
                w.WriteEndAttribute();

                foreach( var item in layer.Items )
                {
                    w.WriteStartElement( "ConfigurationItem" );

                    w.WriteStartAttribute( "ServiceOrPluginId" );
                    w.WriteValue( item.ServiceOrPluginId );
                    w.WriteEndAttribute();

                    w.WriteStartAttribute( "Status" );
                    w.WriteValue( item.Status.ToString() );
                    w.WriteEndAttribute();

                    w.WriteStartAttribute( "Reason" );
                    w.WriteValue( item.StatusReason );
                    w.WriteEndAttribute();

                    w.WriteEndElement();
                }

                w.WriteEndElement();
            }
        }
Esempio n. 7
0
        private static PersistedLabState CreatePersistentObject( LabStateManager runningState )
        {
            PersistedLabState persistedState = new PersistedLabState();

            // Persist layer
            foreach( IConfigurationLayer l in runningState.Engine.Configuration.Layers )
            {
                PersistedConfigurationLayer persistedLayer = new PersistedConfigurationLayer();
                persistedState.ConfigurationLayers.Add( persistedLayer );

                persistedLayer.LayerName = l.LayerName;
                foreach( IConfigurationItem i in l.Items )
                {
                    PersistedConfigurationItem persistedItem = new PersistedConfigurationItem();
                    persistedItem.ServiceOrPluginId = i.ServiceOrPluginFullName;
                    persistedItem.Status = i.Status;
                    persistedItem.StatusReason = i.StatusReason;

                    persistedLayer.Items.Add( persistedItem );
                }
            }

            // Persist service and plugins -- We already have the mocks, so we can use them.
            foreach( ServiceInfo s in runningState.ServiceInfos )
            {
                persistedState.Services.Add( s );
            }
            foreach( PluginInfo p in runningState.PluginInfos )
            {
                persistedState.Plugins.Add( p );
            }

            return persistedState;
        }