Example #1
0
		/// <summary>
		/// True if the next status represents a valid transition from this status.
		/// </summary>
		/// <param name="next">Possible next status.</param>
        /// <param name="allowErrorTransition">True to authorize transitions due to error.</param>
		/// <returns>True if the next status is a valid next one (like <see cref="Starting"/> to <see cref="Started"/>). False otherwise.</returns>
		public bool IsValidTransition( RunningStatus next, bool allowErrorTransition )
		{

            switch( _v )
            {
                case _disabled: return next._v == _stopped;
                case _stopped: return next._v == _starting || next._v == _disabled;
                case _stopping: return next._v == _stopped;
                case _starting: return next._v == _started || (allowErrorTransition && next._v < _starting); //When in Exception, we can pass directly from starting to 'stopping' (and directly to 'stopped' ?)
            }
            // When Started
            return next._v == _stopping;
		}
Example #2
0
        /// <summary>
        /// True if the next status represents a valid transition from this status.
        /// </summary>
        /// <param name="next">Possible next status.</param>
        /// <param name="allowErrorTransition">True to authorize transitions due to error.</param>
        /// <returns>True if the next status is a valid next one (like <see cref="Starting"/> to <see cref="Started"/>). False otherwise.</returns>
        public bool IsValidTransition(RunningStatus next, bool allowErrorTransition)
        {
            switch (_v)
            {
            case _disabled: return(next._v == _stopped);

            case _stopped: return(next._v == _starting || next._v == _disabled);

            case _stopping: return(next._v == _stopped);

            case _starting: return(next._v == _started || (allowErrorTransition && next._v < _starting));    //When in Exception, we can pass directly from starting to 'stopping' (and directly to 'stopped' ?)
            }
            // When Started
            return(next._v == _stopping);
        }
Example #3
0
		protected ServiceProxyBase( object unavailableImpl, Type typeInterface, IList<MethodInfo> mRefs, IList<EventInfo> eRefs )
		{
            Debug.Assert( mRefs.All( r => r != null ) && mRefs.Distinct().SequenceEqual( mRefs ) );
            _typeInterface = typeInterface;
            _status = RunningStatus.Disabled;
            RawImpl = _unavailableImpl = unavailableImpl;
            _mRefs = new MEntry[mRefs.Count];
            for( int i = 0; i < mRefs.Count; i++ )
            {
                _mRefs[i].Method = mRefs[i];
            }
            _eRefs = new EEntry[eRefs.Count];
            for( int i = 0; i < eRefs.Count; i++ )
            {
                _eRefs[i].Event = eRefs[i];
            }
        }
Example #4
0
 private void DoSetPluginStatus( PluginProxy plugin, RunningStatus newOne, RunningStatus previous )
 {
     plugin.Status = newOne;
     var h = StatusChanged;
     if( h != null )
     {
         h( this, new PluginStatusChangedEventArgs( previous, plugin ) );
     }
 }
Example #5
0
 void SetPluginStatus( PluginProxy plugin, RunningStatus newOne, bool allowErrorTransition )
 {
     RunningStatus previous = plugin.Status;
     Debug.Assert( previous != newOne );
     if( newOne > previous )
     {
         // New status is greater than the previous one.
         // We first set the plugin (and raise the event) and then raise the service event (if any).
         DoSetPluginStatus( plugin, newOne, previous );
         if( plugin.IsCurrentServiceImplementation )
         {
             if( newOne == RunningStatus.Stopped && plugin.Service.Status == RunningStatus.Stopped )
             {
                 // This is an consequence of the fact that we disable plugins after 
                 // starting the new ones.
                 // When pA (stopping) implements sA and pB implements sA (starting), sA remains "Stopped".
             }
             else plugin.Service.SetStatusChanged( newOne, allowErrorTransition );
         }
     }
     else
     {
         // New status is lower than the previous one.
         // We first raise the service event (if any) and then the plugin event.
         if( plugin.IsCurrentServiceImplementation ) plugin.Service.SetStatusChanged( newOne, allowErrorTransition );
         DoSetPluginStatus( plugin, newOne, previous );
     }
 }
Example #6
0
 void SetPluginStatus( PluginProxy plugin, RunningStatus newOne )
 {
     SetPluginStatus( plugin, newOne, false );
 }
Example #7
0
        internal void SetStatusChanged( RunningStatus newOne, bool allowErrorTransition )
		{
            Debug.Assert( _status.IsValidTransition( newOne, allowErrorTransition ) );
            RunningStatus previous = _status;
            _status = newOne;
            ConfigureRawImplFromPlugin();
            var h = ServiceStatusChanged;
            if( h != null )
			{
                ServiceStatusChangedEventArgs ev = new ServiceStatusChangedEventArgs( previous, _status, allowErrorTransition );
				h( this, ev );
			}
		}
Example #8
0
 internal void SetStatusChanged( RunningStatus newOne )
 {
     SetStatusChanged( newOne, false );
 }
Example #9
0
 internal void Initialize( ServiceHost serviceHost, bool isExternalService )
 {
     _serviceHost = serviceHost;
     _isExternalService = isExternalService;
     if( isExternalService ) _status = RunningStatus.Started;
 }
        /// <summary>
        /// Initializes a new instance of a <see cref="PluginStatusChangedEventArgs"/>.
        /// </summary>
        /// <param name="previous">The previous running status.</param>
        /// <param name="current">The plugin proxy.</param>
        public PluginStatusChangedEventArgs( RunningStatus previous, IPluginProxy pluginProxy )
		{
			Previous = previous;
			PluginProxy = pluginProxy;
		}
 /// <summary>
 /// Initializes a new instance of a <see cref="PluginStatusChangedEventArgs"/>.
 /// </summary>
 /// <param name="previous">The previous running status.</param>
 /// <param name="current">The plugin proxy.</param>
 public PluginStatusChangedEventArgs(RunningStatus previous, IPluginProxy pluginProxy)
 {
     Previous    = previous;
     PluginProxy = pluginProxy;
 }
        /// <summary>
        /// Initializes a new instance of a <see cref="ServiceStatusChangedEventArgs"/>.
        /// </summary>
        /// <param name="previous">The previous running status.</param>
        /// <param name="current">The current running Status</param>
        /// <param name="allowErrorTransition">True if the next status is a valid next one (like <see cref="RunningStatus.Starting"/> to <see cref="RunningStatus.Started"/>). False otherwise.</param>
		public ServiceStatusChangedEventArgs( RunningStatus previous, RunningStatus current, bool allowErrorTransition )
		{
			Debug.Assert( previous.IsValidTransition( current, allowErrorTransition ) );
			Previous = previous;
			Current = current;
		}
Example #13
0
 /// <summary>
 /// Initializes a new instance of a <see cref="ServiceStatusChangedEventArgs"/>.
 /// </summary>
 /// <param name="previous">The previous running status.</param>
 /// <param name="current">The current running Status</param>
 /// <param name="allowErrorTransition">True if the next status is a valid next one (like <see cref="RunningStatus.Starting"/> to <see cref="RunningStatus.Started"/>). False otherwise.</param>
 public ServiceStatusChangedEventArgs(RunningStatus previous, RunningStatus current, bool allowErrorTransition)
 {
     Debug.Assert(previous.IsValidTransition(current, allowErrorTransition));
     Previous = previous;
     Current  = current;
 }