Exemplo n.º 1
0
        /// <summary>
        /// Creates a case for receiving from the specific channel.
        /// </summary>
        /// <param name="c">The channel to receive from. Can be <c>null</c>.</param>
        /// <param name="func">The function to execute with the data received from the channel. Can be <c>null</c></param>
        /// <returns>An instance to append another Case, Default, or NoDefault. Select must end with a call to
        /// Default or NoDefault.</returns>
        public SelectCase CaseReceive <T>(IReceiveOnlyChan <T> c, Action <T> func = null)
        {
            if (_isExecuteCalled)
            {
                throw new Exception("select already executed");
            }

            if (c != null)
            {
                _receiveFuncs.Add(
                    new ReceiveCase
                {
                    Chan = c
                },
                    func == null
                        ? (Action <object, bool>)null
                        : (v, ok) => func((T)v)
                    );
            }

            return(this);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Creates a case for receiving from the specific channel.
 /// </summary>
 /// <param name="c">The channel to receive from. Can be <c>null</c>.</param>
 /// <param name="func">The function to execute with the data received from the channel.</param>
 /// <returns>An instance to append another Case, Default, or NoDefault. Select must end with a call to
 /// Default or NoDefault.</returns>
 public static SelectCase CaseReceiveOk <T>(IReceiveOnlyChan <T> c, Action <T, bool> func)
 {
     return(new SelectCase().CaseReceiveOk(c, func));
 }
Exemplo n.º 3
0
 /// <summary>
 /// Creates a case for receiving from the specific channel.
 /// </summary>
 /// <param name="c">The channel to receive from. Can be <c>null</c>.</param>
 /// <param name="func">The function to execute with the data received from the channel. Can be <c>null</c></param>
 /// <returns>An instance to append another Case, Default, or NoDefault. Select must end with a call to
 /// Default or NoDefault.</returns>
 public static SelectCase CaseReceive <T>(IReceiveOnlyChan <T> c, Action <T> func = null)
 {
     return(new SelectCase().CaseReceive(c, func));
 }