Пример #1
0
        internal void Bind( ServiceData s, Func<string, LiveServiceInfo> serviceFinder, Func<string, LivePluginInfo> pluginFinder, DelayedPropertyNotification notifier )
        {
            var newGeneralization = s.Generalization != null ? serviceFinder( s.Generalization.ServiceInfo.ServiceFullName ) : null;
            notifier.Update( this, ref _generalization, newGeneralization, () => Generalization );

            var familyRunning = s.Family.DynRunningPlugin;
            Debug.Assert( IsRunning == (familyRunning != null && s.IsGeneralizationOf( familyRunning.Service )) );

            ILivePluginInfo newRunningPlugin = null;
            if( IsRunning )
            {
                newRunningPlugin = pluginFinder( familyRunning.PluginInfo.PluginFullName );
            }
            if( _runningPlugin != null )
            {
                notifier.Update( this, ref _lastRunningPlugin, _runningPlugin, () => LastRunningPlugin );
            }
            notifier.Update( this, ref _runningPlugin, newRunningPlugin, () => RunningPlugin );
        }
Пример #2
0
 protected void UpdateItem( IYodiiItemData d, DelayedPropertyNotification notifier )
 {
     Debug.Assert( d.DynamicStatus != null );
     bool wasRunning = _runningStatus >= RunningStatus.Running;
     var prevFinalSolvedConfig = FinalConfigSolvedStatus;
     _capability.UpdateFrom( d.FinalConfigSolvedStatus, d.FinalStartableStatus, notifier );
     notifier.Update( this, ref _disabledReason, d.DisabledReason, () => DisabledReason );
     notifier.Update( this, ref _runningStatus, d.DynamicStatus.Value, () => RunningStatus );
     notifier.Update( this, ref _configOriginalStatus, d.ConfigOriginalStatus, () => ConfigOriginalStatus );
     notifier.Update( this, ref _configSolvedStatus, d.ConfigSolvedStatus, () => WantedConfigSolvedStatus );
     notifier.Update( this, ref _configOriginalImpact, d.ConfigOriginalImpact, () => ConfigOriginalImpact );
     notifier.Update( this, ref _configSolvedImpact, d.RawConfigSolvedImpact, () => ConfigSolvedImpact );
     if( wasRunning != (_runningStatus >= RunningStatus.Running) )
     {
         notifier.Notify( this, () => IsRunning );
     }
     if( prevFinalSolvedConfig != FinalConfigSolvedStatus )
     {
         notifier.Notify( this, () => FinalConfigSolvedStatus );
     }
 }
Пример #3
0
 internal void UpdateFrom( SolvedConfigurationStatus finalConfigStatus, FinalConfigStartableStatus s, DelayedPropertyNotification notifier )
 {
     AllFlags newOne = new AllFlags( finalConfigStatus, s );
     notifier.Update( this, ref _flags.CanStop, newOne.CanStop, () => CanStop );
     notifier.Update( this, ref _flags.CanStart, newOne.CanStart, () => CanStart );
     notifier.Update( this, ref _flags.CanStartWithFullStart, newOne.CanStartWithFullStart, () => CanStartWithFullStart );
     notifier.Update( this, ref _flags.CanStartWithStartRecommended, newOne.CanStartWithStartRecommended, () => CanStartWithStartRecommended );
     notifier.Update( this, ref _flags.CanStartWithStopOptionalAndRunnable, newOne.CanStartWithStopOptionalAndRunnable, () => CanStartWithStopOptionalAndRunnable );
     notifier.Update( this, ref _flags.CanStartWithFullStop, newOne.CanStartWithFullStop, () => CanStartWithFullStop );
 }
Пример #4
0
 internal void UpdateFrom( ServiceData s, DelayedPropertyNotification notifier )
 {
     UpdateItem( s, notifier );
     notifier.Update( this, ref _serviceInfo, s.ServiceInfo, () => ServiceInfo );
 }
Пример #5
0
 internal void UpdateFrom( PluginData p, DelayedPropertyNotification notifier )
 {
     Debug.Assert( FullName == p.PluginInfo.PluginFullName );
     UpdateItem( p, notifier );
     notifier.Update( this, ref _pluginInfo, p.PluginInfo, () => PluginInfo );
 }
Пример #6
0
 internal void Bind( PluginData p, Func<string, LiveServiceInfo> serviceFinder, DelayedPropertyNotification notifier )
 {
     Debug.Assert( _pluginInfo == p.PluginInfo );
     var newService = p.Service != null ? serviceFinder( p.Service.ServiceInfo.ServiceFullName ) : null;
     notifier.Update( this, ref _service, newService, () => Service );
 }
Пример #7
0
        internal void UpdateFrom( IConfigurationSolver solver )
        {
            // 1 - Removes existing items from live info that do not exist anymore in the new running context.
            //     This raises Collection "item removed" events.
            //
            _services.RemoveWhereAndReturnsRemoved( s => solver.FindService( s.ServiceInfo.ServiceFullName ) == null ).Count();
            _plugins.RemoveWhereAndReturnsRemoved( p => solver.FindPlugin( p.PluginInfo.PluginFullName ) == null ).Count();

            DelayedPropertyNotification notifier = new DelayedPropertyNotification();

            // 2 - Builds two lists of new Services and new Plugins and for already existing ones,
            //     updates them with the new information.
            //     This update does not trigger any ProprtyChanged events and consider only
            //     direct properties of the object.
            //     Changes to linked items (such as a Generalization reference for instance will be
            //     done later thanks to their Bind method.
            //
            List<LiveServiceInfo> servicesToAdd = new List<LiveServiceInfo>();
            foreach( var s in solver.AllServices )
            {
                LiveServiceInfo ls = _services.GetByKey( s.ServiceInfo.ServiceFullName );
                if( ls == null ) servicesToAdd.Add( new LiveServiceInfo( s, _engine ) );
                else ls.UpdateFrom( s, notifier );
            }

            List<LivePluginInfo> pluginsToAdd = new List<LivePluginInfo>();
            foreach( var p in solver.AllPlugins )
            {
                LivePluginInfo lp = _plugins.GetByKey( p.PluginInfo.PluginFullName );
                if( lp == null ) pluginsToAdd.Add( new LivePluginInfo( p, _engine ) );
                else lp.UpdateFrom( p, notifier );
            }

            // 3 - Intrinsic properties have been updated. We now consider the properties that reference other items.
            //
            Func<string,LiveServiceInfo> serviceFinder = name => _services.GetByKey( name ) ?? servicesToAdd.First( ls => ls.ServiceInfo.ServiceFullName == name );
            Func<string,LivePluginInfo> pluginFinder = id => _plugins.GetByKey( id ) ?? pluginsToAdd.First( lp => lp.PluginInfo.PluginFullName == id );

            using( notifier.SilentMode() )
            {
                foreach( var ls in servicesToAdd ) ls.Bind( solver.FindExistingService( ls.ServiceInfo.ServiceFullName ), serviceFinder, pluginFinder, notifier );
            }
            foreach( var ls in _services ) ls.Bind( solver.FindExistingService( ls.ServiceInfo.ServiceFullName ), serviceFinder, pluginFinder, notifier );

            using( notifier.SilentMode() )
            {
                foreach( var lp in pluginsToAdd ) lp.Bind( solver.FindExistingPlugin( lp.PluginInfo.PluginFullName ), serviceFinder, notifier );
            }
            foreach( var lp in _plugins ) lp.Bind( solver.FindExistingPlugin( lp.PluginInfo.PluginFullName ), serviceFinder, notifier );

            // 4 - It is time to add the new comers: this raises Collection changed "item added" events.
            foreach( var ls in servicesToAdd ) _services.Add( ls );
            foreach( var lp in pluginsToAdd ) _plugins.Add( lp );

            // 5 - Raises all PropertyChanged events for all objects.
            notifier.RaiseEvents();
        }