IActivityLoggerClient FindOrCreate(IActivityLogger sender)
 {
     if (_lastSender == sender)
     {
         return(_lastClient);
     }
     if (_lastSender == null)
     {
         _lastClient = CreateClient(sender);
     }
     else
     {
         if (_clients == null)
         {
             _clients = new ListDictionary();
             _clients.Add(_lastSender, _lastClient);
             _lastClient = null;
         }
         else
         {
             _lastClient = (IActivityLoggerClient)_clients[sender];
         }
         if (_lastClient == null)
         {
             _lastClient = CreateClient(sender);
             _clients.Add(sender, _lastClient);
         }
     }
     _lastSender = sender;
     return(_lastClient);
 }
Example #2
0
 /// <summary>
 /// Unregisters the given <see cref="IActivityLoggerClient"/> from the <see cref="RegisteredClients"/> list.
 /// Silently ignores unregistered client but throws an <see cref="InvalidOperationException"/> if it belongs to <see cref="NonRemoveableClients"/> list.
 /// </summary>
 /// <param name="client">An <see cref="IActivityLoggerClient"/> implementation.</param>
 /// <returns>This object to enable fluent syntax.</returns>
 public IActivityLoggerClientRegistrar UnregisterClient(IActivityLoggerClient client)
 {
     if (client == null)
     {
         throw new ArgumentNullException("client");
     }
     if (_nonRemoveableClients.Contains(client))
     {
         throw new InvalidOperationException(R.ActivityLoggerNonRemoveableClient);
     }
     _clients.Remove(client);
     return(this);
 }
Example #3
0
 /// <summary>
 /// Registers an <see cref="IMuxActivityLoggerClient"/> to the <see cref="IMuxActivityLoggerClientRegistrar.RegisteredMuxClients">RegisteredMuxClients</see> list.
 /// Removes the <paramref name="client"/> from <see cref="RegisteredClients"/> if
 /// it is also a <see cref="IActivityLoggerClient"/> to avoid stuttering.
 /// Duplicate IMuxActivityLoggerClient are silently ignored.
 /// </summary>
 /// <param name="client">An <see cref="IMuxActivityLoggerClient"/> implementation.</param>
 /// <returns>This object to enable fluent syntax.</returns>
 public override IMuxActivityLoggerClientRegistrar RegisterMuxClient(IMuxActivityLoggerClient client)
 {
     if (client == null)
     {
         throw new ArgumentNullException("client");
     }
     if (!RegisteredMuxClients.Contains(client))
     {
         IActivityLoggerClient c = client as IActivityLoggerClient;
         if (c != null)
         {
             _clients.Remove(c);
         }
         DoAdd(client);
     }
     return(this);
 }
Example #4
0
 /// <summary>
 /// Registers an <see cref="IActivityLoggerClient"/> to the <see cref="RegisteredClients"/> list.
 /// Removes the <paramref name="client"/> from <see cref="IMuxActivityLoggerClientRegistrar.RegisteredMuxClients">RegisteredMuxClients</see> if
 /// it is also a <see cref="IMuxActivityLoggerClient"/> to avoid stuttering.
 /// Duplicate IActivityLoggerClient are silently ignored.
 /// </summary>
 /// <param name="client">An <see cref="IActivityLoggerClient"/> implementation.</param>
 /// <returns>This object to enable fluent syntax.</returns>
 public IActivityLoggerClientRegistrar RegisterClient(IActivityLoggerClient client)
 {
     if (client == null)
     {
         throw new ArgumentNullException("client");
     }
     if (!_clients.Contains(client))
     {
         IMuxActivityLoggerClient mux = client as IMuxActivityLoggerClient;
         if (mux != null)
         {
             DoRemove(mux);
         }
         _clients.Insert(0, client);
     }
     return(this);
 }
Example #5
0
 public IActivityLoggerClientRegistrar UnregisterClient(IActivityLoggerClient client)
 {
     return(this);
 }
 IActivityLoggerClient FindOrCreate( IActivityLogger sender )
 {
     if( _lastSender == sender ) return _lastClient;
     if( _lastSender == null )
     {
         _lastClient = CreateClient( sender );
     }
     else
     {
         if( _clients == null )
         {
             _clients = new ListDictionary();
             _clients.Add( _lastSender, _lastClient );
             _lastClient = null;
         }
         else _lastClient = (IActivityLoggerClient)_clients[sender];
         if( _lastClient == null )
         {
             _lastClient = CreateClient( sender );
             _clients.Add( sender, _lastClient );
         }
     }
     _lastSender = sender;
     return _lastClient;
 }
Example #7
0
 public IActivityLoggerClientRegistrar UnregisterClient( IActivityLoggerClient client )
 {
     return this;
 }
Example #8
0
 /// <summary>
 /// Unregisters the given <see cref="IActivityLoggerClient"/> from the <see cref="RegisteredClients"/> list.
 /// Silently ignores unregistered client but throws an <see cref="InvalidOperationException"/> if it belongs to <see cref="NonRemoveableClients"/> list.
 /// </summary>
 /// <param name="client">An <see cref="IActivityLoggerClient"/> implementation.</param>
 /// <returns>This object to enable fluent syntax.</returns>
 public IActivityLoggerClientRegistrar UnregisterClient( IActivityLoggerClient client )
 {
     if( client == null ) throw new ArgumentNullException( "client" );
     if( _nonRemoveableClients.Contains( client ) ) throw new InvalidOperationException( R.ActivityLoggerNonRemoveableClient );
     _clients.Remove( client );
     return this;
 }
Example #9
0
 /// <summary>
 /// Registers an <see cref="IActivityLoggerClient"/> to the <see cref="RegisteredClients"/> list.
 /// Removes the <paramref name="client"/> from <see cref="IMuxActivityLoggerClientRegistrar.RegisteredMuxClients">RegisteredMuxClients</see> if
 /// it is also a <see cref="IMuxActivityLoggerClient"/> to avoid stuttering.
 /// Duplicate IActivityLoggerClient are silently ignored.
 /// </summary>
 /// <param name="client">An <see cref="IActivityLoggerClient"/> implementation.</param>
 /// <returns>This object to enable fluent syntax.</returns>
 public IActivityLoggerClientRegistrar RegisterClient( IActivityLoggerClient client )
 {
     if( client == null ) throw new ArgumentNullException( "client" );
     if( !_clients.Contains( client ) )
     {
         IMuxActivityLoggerClient mux = client as IMuxActivityLoggerClient;
         if( mux != null ) DoRemove( mux );
         _clients.Insert( 0, client );
     }
     return this;
 }