Exemple #1
0
        private void ApplyPersistedStateToLab()
        {
            // Stop running engine
            if (state.Engine.IsRunning)
            {
                state.Engine.Stop();
            }

            // Clear configuration manager
            foreach (var l in state.Engine.Configuration.Layers.ToList())
            {
                var result = state.Engine.Configuration.Layers.Remove(l);
                Debug.Assert(result.Success);
            }

            // Clear services and plugins
            state.ClearState();

            // Add services and plugins
            foreach (ServiceInfo s in deserializedState.Services)
            {
                state.LoadServiceInfo(s);
            }
            foreach (PluginInfo p in deserializedState.Plugins)
            {
                state.LoadPluginInfo(p);
            }

            // Load configuration manager data
            foreach (PersistedConfigurationLayer l in deserializedState.ConfigurationLayers)
            {
                IConfigurationLayer newLayer = state.Engine.Configuration.Layers.Create(l.LayerName);

                foreach (PersistedConfigurationItem item in l.Items)
                {
                    var result = newLayer.Items.Add(item.ServiceOrPluginId, item.Status, item.StatusReason);
                    Debug.Assert(result.Success);
                }
            }
        }