Example #1
0
 void IActivityMonitorBoundClient.SetMonitor( IActivityMonitorImpl source, bool forceBuggyRemove )
 {
     if( source != null && _source != null ) throw ActivityMonitorClient.CreateMultipleRegisterOnBoundClientException( this );
     // Silently ignore null => null or monitor => same monitor.
     if( source != _source )
     {
         _prevLogType = LogEntryType.None;
         _prevlogTime = DateTimeStamp.Unknown;
         Debug.Assert( (source == null) != (_source == null) );
         if( (_source = source) == null )
         {
             if( _file != null ) _file.Close();
             _file = null;
         }
         else
         {
             // If initialization failed, we let the file null: this monitor will not
             // work (the error will appear in the Critical errors) but this avoids
             // an exception to be thrown here.
             var f = new MonitorBinaryFileOutput( _path, ((IUniqueId)_source).UniqueId, _maxCountPerFile, _useGzipCompression );
             if( f.Initialize( new SystemActivityMonitor( false, null ) ) )
             {
                 var g = _source.CurrentGroup;
                 _currentGroupDepth = g != null ? g.Depth : 0;
                 _file = f;
             }
         }
     }
 }
Example #2
0
 void IActivityMonitorBoundClient.SetMonitor(IActivityMonitorImpl source, bool forceBuggyRemove)
 {
     if (source != null && _source != null)
     {
         throw ActivityMonitorClient.CreateMultipleRegisterOnBoundClientException(this);
     }
     // Silently ignore null => null or monitor => same monitor.
     if (source != _source)
     {
         _prevLogType = LogEntryType.None;
         _prevlogTime = DateTimeStamp.Unknown;
         Debug.Assert((source == null) != (_source == null));
         if ((_source = source) == null)
         {
             if (_file != null)
             {
                 _file.Close();
             }
             _file = null;
         }
         else
         {
             // If initialization failed, we let the file null: this monitor will not
             // work (the error will appear in the Critical errors) but this avoids
             // an exception to be thrown here.
             var f = new MonitorBinaryFileOutput(_path, ((IUniqueId)_source).UniqueId, _maxCountPerFile, _useGzipCompression);
             if (f.Initialize(new SystemActivityMonitor(false, null)))
             {
                 var g = _source.CurrentGroup;
                 _currentGroupDepth = g != null ? g.Depth : 0;
                 _file = f;
             }
         }
     }
 }
 /// <summary>
 /// forceBuggyRemove is not used here since this client is not lockable.
 /// </summary>
 void IActivityMonitorBoundClient.SetMonitor(Impl.IActivityMonitorImpl source, bool forceBuggyRemove)
 {
     if (source != null && _source != null)
     {
         throw ActivityMonitorClient.CreateMultipleRegisterOnBoundClientException(this);
     }
     if (_source != null)
     {
         _bridgeTarget.RemoveCallback(this);
         // Unregistering.
         for (int i = 0; i < _openedGroups.Count; ++i)
         {
             if (_openedGroups[i])
             {
                 _targetMonitor.CloseGroup(new ActivityLogGroupConclusion(ActivityMonitorResources.ClosedByBridgeRemoved, TagBridgePrematureClose));
             }
         }
         _openedGroups.Clear();
     }
     else
     {
         _bridgeTarget.AddCallback(this);
         _targetActualFilter = _bridgeTarget.TargetFinalFilter;
         if (_pullTargetTopicAndAutoTagsFromTarget)
         {
             source.InitializeTopicAndAutoTags(this._targetMonitor.Topic, _targetMonitor.AutoTags);
         }
     }
     _source = source;
     Interlocked.MemoryBarrier();
 }
 public void SetMonitor(IActivityMonitorImpl source, bool forceBuggyRemove)
 {
     if (!forceBuggyRemove && source == null)
     {
         throw new InvalidOperationException();
     }
 }
 /// <summary>
 /// Initializes a new <see cref="ActivityMonitorBridgeTarget"/> bound to a <see cref="IActivityMonitor"/>.
 /// </summary>
 /// <param name="targetMonitor">Monitor that will receive the logs.</param>
 /// <param name="honorMonitorFilter">
 /// False to ignore the actual filter <see cref="IActivityMonitor.ActualFilter"/> value: logs coming from the bridge (ie. the remote Application Domain)
 /// will always be added to this target monitor.
 /// </param>
 public ActivityMonitorBridgeTarget( IActivityMonitorImpl targetMonitor, bool honorMonitorFilter = true )
 {
     if( targetMonitor == null ) throw new ArgumentNullException( "targetMonitor" );
     _monitor = targetMonitor;
     _honorTargetFilter = honorMonitorFilter;
     _callbacks = Util.Array.Empty<IActivityMonitorBridgeCallback>();
 }
Example #6
0
 /// <summary>
 /// forceBuggyRemove is not used here since this client is not lockable.
 /// </summary>
 void IActivityMonitorBoundClient.SetMonitor(IActivityMonitorImpl source, bool forceBuggyRemove)
 {
     if (source != null && _monitorSource != null)
     {
         throw ActivityMonitorClient.CreateMultipleRegisterOnBoundClientException(this);
     }
     // Silently ignore null => null or monitor => same monitor.
     if (source != _monitorSource)
     {
         _currentMinimalFilter = LogFilter.Undefined;
         _prevLogType          = LogEntryType.None;
         _prevlogTime          = DateTimeStamp.Unknown;
         Debug.Assert((source == null) != (_monitorSource == null));
         if ((_monitorSource = source) == null)
         {
             // Releases the channel if any.
             _channel = null;
         }
         else
         {
             var g = _monitorSource.CurrentGroup;
             _currentGroupDepth = g != null ? g.Depth : 0;
             Interlocked.Increment(ref _version);
         }
     }
 }
 /// <summary>
 /// Initializes a new <see cref="ActivityMonitorOutput"/> bound to a <see cref="IActivityMonitor"/>.
 /// </summary>
 /// <param name="monitor"></param>
 public ActivityMonitorOutput(IActivityMonitorImpl monitor)
 {
     if (monitor == null)
     {
         throw new ArgumentNullException();
     }
     _monitor       = monitor;
     _clients       = Util.Array.Empty <IActivityMonitorClient>();
     _externalInput = new ActivityMonitorBridgeTarget(monitor, true);
 }
 void IActivityMonitorBoundClient.SetMonitor( IActivityMonitorImpl source, bool forceBuggyRemove )
 {
     if( source != null && _source != null ) throw ActivityMonitorClient.CreateMultipleRegisterOnBoundClientException( this );
     if( source != null )
     {
         Interlocked.Exchange( ref _text, Util.Array.Empty<string>() );
         _source = source;
     }
     else _source = null;
 }
 /// <summary>
 /// Initializes a new <see cref="ActivityMonitorBridgeTarget"/> bound to a <see cref="IActivityMonitor"/>.
 /// </summary>
 /// <param name="targetMonitor">Monitor that will receive the logs.</param>
 /// <param name="honorMonitorFilter">
 /// False to ignore the actual filter <see cref="IActivityMonitor.ActualFilter"/> value: logs coming from the bridge (ie. the remote Application Domain)
 /// will always be added to this target monitor.
 /// </param>
 public ActivityMonitorBridgeTarget(IActivityMonitorImpl targetMonitor, bool honorMonitorFilter = true)
 {
     if (targetMonitor == null)
     {
         throw new ArgumentNullException("targetMonitor");
     }
     _monitor           = targetMonitor;
     _honorTargetFilter = honorMonitorFilter;
     _callbacks         = Util.Array.Empty <IActivityMonitorBridgeCallback>();
 }
 void IActivityMonitorBoundClient.SetMonitor(IActivityMonitorImpl source, bool forceBuggyRemove)
 {
     if (!forceBuggyRemove)
     {
         if (source != null && _source != null)
         {
             throw CreateMultipleRegisterOnBoundClientException(this);
         }
     }
     _source = source;
 }
Example #11
0
 void IActivityMonitorBoundClient.SetMonitor(IActivityMonitorImpl source, bool forceBuggyRemove)
 {
     if (source != null && _source != null)
     {
         throw ActivityMonitorClient.CreateMultipleRegisterOnBoundClientException(this);
     }
     if (source != null)
     {
         Interlocked.Exchange(ref _text, Util.Array.Empty <string>());
         _source = source;
     }
     else
     {
         _source = null;
     }
 }
Example #12
0
 /// <summary>
 /// forceBuggyRemove is not used here since this client is not lockable.
 /// </summary>
 void IActivityMonitorBoundClient.SetMonitor( IActivityMonitorImpl source, bool forceBuggyRemove )
 {
     if( source != null && _monitorSource != null ) throw ActivityMonitorClient.CreateMultipleRegisterOnBoundClientException( this );
     // Silently ignore null => null or monitor => same monitor.
     if( source != _monitorSource )
     {
         _currentMinimalFilter = LogFilter.Undefined;
         _prevLogType = LogEntryType.None;
         _prevlogTime = DateTimeStamp.Unknown;
         Debug.Assert( (source == null) != (_monitorSource == null) );
         if( (_monitorSource = source) == null )
         {
             // Releases the channel if any.
             _channel = null;
         }
         else
         {
             var g = _monitorSource.CurrentGroup;
             _currentGroupDepth = g != null ? g.Depth : 0;
             Interlocked.Increment( ref _version );
         }
     }
 }
        /// <summary>
        /// forceBuggyRemove is not used here since this client is not lockable.
        /// </summary>
        void IActivityMonitorBoundClient.SetMonitor( Impl.IActivityMonitorImpl source, bool forceBuggyRemove )
        {
            if( source != null && _source != null ) throw ActivityMonitorClient.CreateMultipleRegisterOnBoundClientException( this );
            if( _source != null )
            {
                _bridgeTarget.RemoveCallback( this );
                // Unregistering.
                for( int i = 0; i < _openedGroups.Count; ++i )
                {
                    if( _openedGroups[i] )
                    {
                        _targetMonitor.CloseGroup( new ActivityLogGroupConclusion( ActivityMonitorResources.ClosedByBridgeRemoved, TagBridgePrematureClose ) );
                    }
                }
                _openedGroups.Clear();
            }
            else
            {
                _bridgeTarget.AddCallback( this );
                _targetActualFilter = _bridgeTarget.TargetFinalFilter;
                if( _pullTargetTopicAndAutoTagsFromTarget )
                {
                    source.InitializeTopicAndAutoTags( this._targetMonitor.Topic, _targetMonitor.AutoTags );
                }

            }
            _source = source;
            Interlocked.MemoryBarrier();
        }
 void IActivityMonitorBoundClient.SetMonitor( IActivityMonitorImpl source, bool forceBuggyRemove )
 {
     if( !forceBuggyRemove )
     {
         if( source != null && _source != null ) throw CreateMultipleRegisterOnBoundClientException( this );
     }
     _source = source;
 }
 public void SetMonitor( IActivityMonitorImpl source, bool forceBuggyRemove )
 {
     if( !forceBuggyRemove && source == null ) throw new InvalidOperationException();
 }