NotDisposed() public static méthode

Throws an exception if the specified object has been disposed.
public static NotDisposed ( DisposableObject obj ) : void
obj DisposableObject The object in question.
Résultat void
Exemple #1
0
        /// <summary>
        /// Closes a channel, removing it from the message broker.
        /// </summary>
        /// <param name="name">The name of the channel to close.</param>
        public void CloseChannel(string name)
        {
            Ensure.NotDisposed(this);
            ThrowIfChannelDoesNotExist(name);

            IMessageChannel channel = _channels[name];

            channel.Dispose();

            _channels.Remove(name);
        }
Exemple #2
0
        /// <summary>
        /// Returns a channel with the specified name, creating it first if necessary.
        /// </summary>
        /// <param name="name">The name of the channel to create or retrieve.</param>
        /// <returns>The object representing the channel.</returns>
        public IMessageChannel GetChannel(string name)
        {
            Ensure.NotDisposed(this);

            if (!_channels.ContainsKey(name))
            {
                var factory = Kernel.Components.Get <IMessageChannelFactory>();
                _channels.Add(name, factory.Create(name));
            }

            return(_channels[name]);
        }
Exemple #3
0
 /// <summary>
 /// Disables a channel, which will block messages from being passed.
 /// </summary>
 /// <param name="name">The name of the channel to disable.</param>
 public void DisableChannel(string name)
 {
     Ensure.NotDisposed(this);
     ThrowIfChannelDoesNotExist(name);
     _channels[name].Disable();
 }