Exemplo n.º 1
0
        /// <summary>
        /// 戻り値のコマンドが実行されるまで待つよう、<see cref="Channel{TMessage}.SetHandler{T}(AsyncChannelHandler{TMessage})"/> を設定する。
        /// </summary>
        /// <typeparam name="TMessage"></typeparam>
        /// <typeparam name="T"></typeparam>
        /// <typeparam name="TResponse"></typeparam>
        /// <param name="channel"></param>
        /// <returns></returns>
        public static ICommand SetCommand <TMessage, T, TResponse>(this Channel <TMessage> channel)
            where T : TMessage, IResponsiveMessage <TResponse>
        {
            var c = new ObservableCommand <TResponse>();

            channel.SetHandler <T>(async m => m.Response = await c.FirstAsync().ToTask());
            return(c);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 戻り値のコマンドが実行されるまで待つよう、<see cref="Channel{TMessage}.SetHandler{T}(AsyncChannelHandler{TMessage})"/> を設定する。
        /// </summary>
        /// <typeparam name="TMessage"></typeparam>
        /// <typeparam name="T"></typeparam>
        /// <param name="channel"></param>
        /// <returns></returns>
        public static ICommand SetCommand <TMessage, T>(this Channel <TMessage> channel)
            where T : TMessage
        {
            var c = new ObservableCommand();

            channel.SetHandler <T>(m => c.FirstAsync().ToTask());
            return(c);
        }