/// <summary> /// Creates a new instance of this LabStateManager, as well as a new IYodiiEngine. /// </summary> internal LabStateManager() { YodiiEngine engine = new YodiiEngine(this); _engine = engine; Debug.Assert(_engine.LiveInfo != null); _engine.PropertyChanged += _engine_PropertyChanged; _engine.LiveInfo.Plugins.CollectionChanged += Plugins_CollectionChanged; _engine.LiveInfo.Services.CollectionChanged += Services_CollectionChanged; Debug.Assert(_engine.IsRunning == false); _serviceInfos = new CKObservableSortedArrayKeyList <ServiceInfo, string>(s => s.ServiceFullName, false); _pluginInfos = new CKObservableSortedArrayKeyList <PluginInfo, string>(p => p.PluginFullName, false); _labServiceInfos = new CKObservableSortedArrayKeyList <LabServiceInfo, ServiceInfo>(s => s.ServiceInfo, (x, y) => String.CompareOrdinal(x.ServiceFullName, y.ServiceFullName), false); _labPluginInfos = new CKObservableSortedArrayKeyList <LabPluginInfo, PluginInfo>(p => p.PluginInfo, (x, y) => String.CompareOrdinal(x.PluginFullName, y.PluginFullName), false); _runningPlugins = new ObservableCollection <IPluginInfo>(); _serviceInfos.CollectionChanged += _serviceInfos_CollectionChanged; _pluginInfos.CollectionChanged += _pluginInfos_CollectionChanged; UpdateEngineInfos(); }
/// <summary> /// Static failure resolution constructor. /// </summary> public YodiiEngineResult(IConfigurationSolver solver, List <PluginData> blockingPlugins, List <ServiceData> blockingServices, YodiiEngine engine) { Debug.Assert(blockingPlugins != null || blockingServices != null, "At least one must not be null."); Debug.Assert(solver != null); Debug.Assert(engine != null); var allP = solver.AllPlugins.Select(p => new SolvedPluginSnapshot(p)).ToDictionary(p => p.PluginInfo); var allS = solver.AllServices.Select(s => new SolvedServiceSnapshot(s)).ToDictionary(s => s.ServiceInfo.ServiceFullName); _staticOnlyResultConfiguration = new StaticSolvedConfiguration(allP.Values.ToReadOnlyList(), allS.Values.ToReadOnlyList()); var blkP = blockingPlugins == null ? CKReadOnlyListEmpty <IStaticSolvedPlugin> .Empty : blockingPlugins.Select(p => allP[p.PluginInfo]).ToReadOnlyList(); _pluginCulprits = blkP.Select(ps => ps.PluginInfo).ToReadOnlyList(); var blkS = blockingServices == null ? CKReadOnlyListEmpty <IStaticSolvedService> .Empty : blockingServices.Select(s => allS[s.ServiceInfo.ServiceFullName]).ToReadOnlyList(); _serviceCulprits = blkS.Select(ss => ss.ServiceInfo).ToReadOnlyList(); _engine = engine; _staticFailureResult = new StaticFailureResult(_staticOnlyResultConfiguration, blkP, blkS); }
/// <summary> /// Configuration failure constructor. /// </summary> internal YodiiEngineResult(IConfigurationFailureResult configurationFailureResult, YodiiEngine engine) { Debug.Assert(configurationFailureResult.FailureReasons != null && configurationFailureResult.FailureReasons.Count > 0); _engine = engine; _configurationFailureResult = configurationFailureResult; }
/// <summary> /// Creates a new instance of this ViewModel. /// </summary> /// <param name="loadDefaultState">True if the default XML state should be loaded, false to start on an empty state.</param> public MainWindowViewModel( bool loadDefaultState = false ) { _recentFiles = new CKObservableSortedArrayList<RecentFile>( ( a, b ) => DateTime.Compare( b.AccessTime, a.AccessTime ) ); // Lab objects, live objects and static infos are managed in the LabStateManager. _labStateManager = new LabStateManager(); _engine = _labStateManager.Engine; _labStateManager.Engine.PropertyChanged += Engine_PropertyChanged; _labStateManager.ServiceInfos.CollectionChanged += ServiceInfos_CollectionChanged; _labStateManager.PluginInfos.CollectionChanged += PluginInfos_CollectionChanged; _labStateManager.RunningPlugins.CollectionChanged += RunningPlugins_CollectionChanged; _engine.Configuration.Layers.CollectionChanged += Layers_CollectionChanged; _activityMonitor = new ActivityMonitor(); _activityMonitor.OpenTrace().Send( "Hello world" ); _graph = new YodiiGraph( _engine.Configuration, _labStateManager ); _removeSelectedVertexCommand = new RelayCommand( RemoveSelectedVertexExecute, CanEditSelectedVertex ); _toggleEngineCommand = new RelayCommand( ToggleEngineExecute ); _openFileCommand = new RelayCommand( OpenFileExecute ); _saveAsFileCommand = new RelayCommand( SaveAsFileExecute ); _saveCommand = new RelayCommand( SaveExecute ); // Save is always available.e _reorderGraphLayoutCommand = new RelayCommand( ReorderGraphLayoutExecute ); _createPluginCommand = new RelayCommand( CreatePluginExecute, CanEditItems ); _createServiceCommand = new RelayCommand( CreateServiceExecute, CanEditItems ); _openConfigurationEditorCommand = new RelayCommand( OpenConfigurationEditorExecute ); _newFileCommand = new RelayCommand( NewFileExecute ); _revokeAllCommandsCommand = new RelayCommand( RevokeAllCommandsExecute, CanRevokeAllCommands ); _autoPositionCommand = new RelayCommand( AutoPositionExecute ); LoadRecentFiles(); // Appication is only available on WPF context. if( Application.Current != null ) { _autosaveTimer = new DispatcherTimer( DispatcherPriority.Background, Application.Current.Dispatcher ); } else { _autosaveTimer = new DispatcherTimer( DispatcherPriority.Background, Dispatcher.CurrentDispatcher ); } _autosaveTimer.Interval = new TimeSpan( 0, 0, 5 ); _autosaveTimer.Tick += AutosaveTick; // Autosave timer is started from outside, using StartAutosaveTimer(). if( loadDefaultState ) LoadDefaultState(); }
/// <summary> /// Static only success resolution constructor. /// </summary> public YodiiEngineResult( IConfigurationSolver solver, YodiiEngine engine ) { Debug.Assert( solver != null ); Debug.Assert( engine != null ); var allP = solver.AllPlugins.Select( p => new SolvedPluginSnapshot( p ) ).ToDictionary( p => p.PluginInfo ); var allS = solver.AllServices.Select( s => new SolvedServiceSnapshot( s ) ).ToDictionary( s => s.ServiceInfo.ServiceFullName ); _staticOnlyResultConfiguration = new StaticSolvedConfiguration( allP.Values.ToReadOnlyList(), allS.Values.ToReadOnlyList() ); _pluginCulprits = CKReadOnlyListEmpty<IPluginInfo>.Empty; _serviceCulprits = CKReadOnlyListEmpty<IServiceInfo>.Empty; _engine = engine; }
public void RuntimeAssertionTest() { IYodiiEngine engine = MockXmlUtils.CreateEngineFromXmlResource("BaseGraph4"); engine.Start(); var rootIService2 = engine.LiveInfo.Services.Where(s => s.FullName == "IService2").First(); var layer = engine.Configuration.Layers.Create("DefautLayer"); var result = layer.Items.Add("IService2", ConfigurationStatus.Disabled); Assert.That(result.Success == false); }
/// <summary> /// Static only success resolution constructor. /// </summary> public YodiiEngineResult(IConfigurationSolver solver, YodiiEngine engine) { Debug.Assert(solver != null); Debug.Assert(engine != null); var allP = solver.AllPlugins.Select(p => new SolvedPluginSnapshot(p)).ToDictionary(p => p.PluginInfo); var allS = solver.AllServices.Select(s => new SolvedServiceSnapshot(s)).ToDictionary(s => s.ServiceInfo.ServiceFullName); _staticOnlyResultConfiguration = new StaticSolvedConfiguration(allP.Values.ToReadOnlyList(), allS.Values.ToReadOnlyList()); _pluginCulprits = CKReadOnlyListEmpty <IPluginInfo> .Empty; _serviceCulprits = CKReadOnlyListEmpty <IServiceInfo> .Empty; _engine = engine; }
/// <summary> /// Dynamic failure constructor. /// </summary> internal YodiiEngineResult(IConfigurationSolver solver, IEnumerable <Tuple <IPluginInfo, Exception> > errorInfo, YodiiEngine engine) { Debug.Assert(solver != null); Debug.Assert(errorInfo != null && errorInfo.Any()); Debug.Assert(engine != null); var allP = solver.AllPlugins.Select(p => new SolvedPluginSnapshot(p)).ToDictionary(ps => ps.PluginInfo); var allS = solver.AllServices.Select(s => new SolvedServiceSnapshot(s)).ToReadOnlyList(); var errors = errorInfo.Select(e => new PluginRuntimeError(allP[e.Item1], e.Item2)).ToReadOnlyList(); _pluginCulprits = errors.Select(e => e.Plugin.PluginInfo).ToReadOnlyList(); _serviceCulprits = _pluginCulprits.Select(p => p.Service).Where(s => s != null).ToReadOnlyList(); _engine = engine; _hostFailureResult = new DynamicFailureResult(new DynamicSolvedConfiguration(allP.Values.ToReadOnlyList(), allS), errors); }
/// <summary> /// Static failure resolution constructor. /// </summary> public YodiiEngineResult( IConfigurationSolver solver, List<PluginData> blockingPlugins, List<ServiceData> blockingServices, YodiiEngine engine ) { Debug.Assert( blockingPlugins != null || blockingServices != null, "At least one must not be null." ); Debug.Assert( solver != null ); Debug.Assert( engine != null ); var allP = solver.AllPlugins.Select( p => new SolvedPluginSnapshot( p ) ).ToDictionary( p => p.PluginInfo ); var allS = solver.AllServices.Select( s => new SolvedServiceSnapshot( s ) ).ToDictionary( s => s.ServiceInfo.ServiceFullName ); _staticOnlyResultConfiguration = new StaticSolvedConfiguration( allP.Values.ToReadOnlyList(), allS.Values.ToReadOnlyList() ); var blkP = blockingPlugins == null ? CKReadOnlyListEmpty<IStaticSolvedPlugin>.Empty : blockingPlugins.Select( p => allP[p.PluginInfo] ).ToReadOnlyList(); _pluginCulprits = blkP.Select( ps => ps.PluginInfo ).ToReadOnlyList(); var blkS = blockingServices == null ? CKReadOnlyListEmpty<IStaticSolvedService>.Empty : blockingServices.Select( s => allS[s.ServiceInfo.ServiceFullName] ).ToReadOnlyList(); _serviceCulprits = blkS.Select( ss => ss.ServiceInfo ).ToReadOnlyList(); _engine = engine; _staticFailureResult = new StaticFailureResult( _staticOnlyResultConfiguration, blkP, blkS ); }
/// <summary> /// Configuration failure constructor. /// </summary> internal YodiiEngineResult( IConfigurationFailureResult configurationFailureResult, YodiiEngine engine ) { Debug.Assert( configurationFailureResult.FailureReasons != null && configurationFailureResult.FailureReasons.Count > 0 ); _engine = engine; _configurationFailureResult = configurationFailureResult; }
/// <summary> /// Dynamic failure constructor. /// </summary> internal YodiiEngineResult( IConfigurationSolver solver, IEnumerable<Tuple<IPluginInfo, Exception>> errorInfo, YodiiEngine engine ) { Debug.Assert( solver != null ); Debug.Assert( errorInfo != null && errorInfo.Any() ); Debug.Assert( engine != null ); var allP = solver.AllPlugins.Select( p => new SolvedPluginSnapshot( p ) ).ToDictionary( ps => ps.PluginInfo ); var allS = solver.AllServices.Select( s => new SolvedServiceSnapshot( s ) ).ToReadOnlyList(); var errors = errorInfo.Select( e => new PluginRuntimeError( allP[e.Item1], e.Item2 ) ).ToReadOnlyList(); _pluginCulprits = errors.Select( e => e.Plugin.PluginInfo ).ToReadOnlyList(); _serviceCulprits = _pluginCulprits.Select( p => p.Service ).Where( s => s != null ).ToReadOnlyList(); _engine = engine; _hostFailureResult = new DynamicFailureResult( new DynamicSolvedConfiguration( allP.Values.ToReadOnlyList(), allS ), errors ); }
/// <summary> /// Asserts that both engines have equivalent static infos. /// </summary> /// <param name="a">A</param> /// <param name="b">B</param> public static void AssertEngineInfoEquivalence(IYodiiEngine a, IYodiiEngine b) { AssertDiscoveredInfoEquivalence(a.DiscoveredInfo, b.DiscoveredInfo); AssertManagerEquivalence(a.Configuration, b.Configuration); }
/// <summary> /// Asserts that both engines have equivalent static infos. /// </summary> /// <param name="a">A</param> /// <param name="b">B</param> public static void AssertEngineInfoEquivalence(IYodiiEngine a, IYodiiEngine b) { AssertDiscoveredInfoEquivalence( a.DiscoveredInfo, b.DiscoveredInfo ); AssertManagerEquivalence( a.Configuration, b.Configuration ); }
/// <summary> /// Creates a new instance of this LabStateManager, as well as a new IYodiiEngine. /// </summary> internal LabStateManager() { YodiiEngine engine = new YodiiEngine( this ); _engine = engine; Debug.Assert( _engine.LiveInfo != null ); _engine.PropertyChanged += _engine_PropertyChanged; _engine.LiveInfo.Plugins.CollectionChanged += Plugins_CollectionChanged; _engine.LiveInfo.Services.CollectionChanged += Services_CollectionChanged; Debug.Assert( _engine.IsRunning == false ); _serviceInfos = new CKObservableSortedArrayKeyList<ServiceInfo, string>( s => s.ServiceFullName, false ); _pluginInfos = new CKObservableSortedArrayKeyList<PluginInfo, string>( p => p.PluginFullName, false ); _labServiceInfos = new CKObservableSortedArrayKeyList<LabServiceInfo, ServiceInfo>( s => s.ServiceInfo, ( x, y ) => String.CompareOrdinal( x.ServiceFullName, y.ServiceFullName ), false ); _labPluginInfos = new CKObservableSortedArrayKeyList<LabPluginInfo, PluginInfo>( p => p.PluginInfo, ( x, y ) => String.CompareOrdinal( x.PluginFullName, y.PluginFullName ), false ); _runningPlugins = new ObservableCollection<IPluginInfo>(); _serviceInfos.CollectionChanged += _serviceInfos_CollectionChanged; _pluginInfos.CollectionChanged += _pluginInfos_CollectionChanged; UpdateEngineInfos(); }
public SuccessYodiiEngineResult( YodiiEngine engine ) { _engine = engine; }
public SuccessYodiiEngineResult(YodiiEngine engine) { _engine = engine; }