Esempio n. 1
0
        /// <summary>
        /// Adds a channel write case to the builder.  If this case wins due to successfully
        /// being able to write data to the channel, the specified action will be invoked.
        /// </summary>
        /// <typeparam name="T">Specifies the type of data in the channel.</typeparam>
        /// <param name="channel">The channel to which to write.</param>
        /// <param name="item">The data to write to the channel.</param>
        /// <param name="action">The synchronous action to invoke once the write is successful.</param>
        /// <returns>This builder.</returns>
        public CaseBuilder CaseWrite <T>(WritableChannel <T> channel, T item, Action action)
        {
            if (channel == null)
            {
                throw new ArgumentNullException(nameof(channel));
            }
            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }

            _cases.Add(new SyncWriteCase <T>(channel, item, action));
            return(this);
        }
Esempio n. 2
0
        /// <summary>
        /// Adds a channel write case to the builder.  If this case wins due to successfully
        /// being able to write data to the channel, the specified action will be invoked.
        /// </summary>
        /// <typeparam name="T">Specifies the type of data in the channel.</typeparam>
        /// <param name="channel">The channel to which to write.</param>
        /// <param name="item">The data to write to the channel.</param>
        /// <param name="func">The asynchronous function to invoke once the write is successful.</param>
        /// <returns>This builder.</returns>
        public CaseBuilder CaseWrite <T>(WritableChannel <T> channel, T item, Func <Task> func)
        {
            if (channel == null)
            {
                throw new ArgumentNullException(nameof(channel));
            }
            if (func == null)
            {
                throw new ArgumentNullException(nameof(func));
            }

            _cases.Add(new AsyncWriteCase <T>(channel, item, func));
            return(this);
        }
 internal ChannelObserver(WritableChannel <T> channel)
 {
     Debug.Assert(channel != null);
     _channel = channel;
 }
Esempio n. 4
0
 internal AsyncWriteCase(WritableChannel <T> channel, T item, Func <Task> action)
 {
     _channel = channel;
     _item    = item;
     _action  = action;
 }
Esempio n. 5
0
 internal SyncWriteCase(WritableChannel <T> channel, T item, Action action)
 {
     _channel = channel;
     _item    = item;
     _action  = action;
 }