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); }
private PersistedConfigurationLayer DeserializeConfigurationLayer(XmlReader r) { PersistedConfigurationLayer newLayer = new PersistedConfigurationLayer(); // We're already inside a ConfigurationLayer element. r.Read(); newLayer.LayerName = r.GetAttribute("Name"); while (r.Read()) { if (r.IsStartElement() && r.Name == "ConfigurationItem") { PersistedConfigurationItem item = new PersistedConfigurationItem(); item.ServiceOrPluginId = r.GetAttribute("ServiceOrPluginId"); item.Status = (ConfigurationStatus)Enum.Parse(typeof(ConfigurationStatus), r.GetAttribute("Status")); item.StatusReason = r.GetAttribute("Reason"); newLayer.Items.Add(item); } } return(newLayer); }
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; }
private PersistedConfigurationLayer DeserializeConfigurationLayer( XmlReader r ) { PersistedConfigurationLayer newLayer = new PersistedConfigurationLayer(); // We're already inside a ConfigurationLayer element. r.Read(); newLayer.LayerName = r.GetAttribute( "Name" ); while( r.Read() ) { if( r.IsStartElement() && r.Name == "ConfigurationItem" ) { PersistedConfigurationItem item = new PersistedConfigurationItem(); item.ServiceOrPluginId = r.GetAttribute( "ServiceOrPluginId" ); item.Status = (ConfigurationStatus)Enum.Parse( typeof( ConfigurationStatus ), r.GetAttribute( "Status" ) ); item.StatusReason = r.GetAttribute( "Reason" ); newLayer.Items.Add( item ); } } return newLayer; }