Beispiel #1
0
 /// <summary>
 /// Executes the first command and then when it completes executes the second command.  The second command
 /// returns TOutput, and the returned command also returns TOutput when executed.
 /// </summary>
 /// <param name="first">The command to execute first</param>
 /// <param name="second">The command to execute second</param>
 /// <returns>The new command that executes both commands in turn.</returns>
 public static IRxFunction <TOutput> Combine <TOutput>(this IRxCommand first, IRxFunction <TOutput> second)
 {
     return(RxFunction.CreateAsync(async() =>
     {
         await first.InvokeAsync();
         return await second.InvokeAsync();
     }));
 }
Beispiel #2
0
 /// <summary>
 /// Executes the first command and then when it completes executes the second command.  The first command returns
 /// TOutput. The second command expects TInput as an argument. The returned command also expects TInput when executed
 /// and returns TOutput.
 /// </summary>
 /// <param name="first">The command to execute first</param>
 /// <param name="second">The command to execute second</param>
 /// <returns>The new command that executes both commands in turn.</returns>
 public static IRxFunction <TInput, TOutput> Combine <TInput, TOutput>(this IRxFunction <TOutput> first, IRxCommand <TInput> second)
 {
     return(RxFunction.CreateAsync <TInput, TOutput>(async x =>
     {
         var result = await first.InvokeAsync();
         await second.InvokeAsync(x);
         return result;
     }));
 }
Beispiel #3
0
 /// <summary>
 /// Converts an IRxFunction&lt;TOutput&gt; into an IRxCommand.  This can be useful with methods such as
 /// Combine which expect particular types of commands that may not fit the command you have in order to
 /// get the behavor you otherwise expect.  The value returned from the function is simply discarded.
 /// </summary>
 public static IRxCommand <TInput> AsCommand <TInput, TOutput>(this IRxFunction <TInput, TOutput> function)
 {
     return(RxCommand.Create <TInput>(x => function.InvokeAsync(x)));
 }
Beispiel #4
0
 /// <summary>
 /// Converts an IRxFunction&lt;TOutput&gt; into an IRxCommand.  This can be useful with methods such as
 /// Combine which expect particular types of commands that may not fit the command you have in order to
 /// get the behavor you otherwise expect.  The value returned from the function is simply discarded.
 /// </summary>
 public static IRxCommand AsCommand <TOutput>(this IRxFunction <TOutput> function)
 {
     return(RxCommand.Create(() => function.InvokeAsync()));
 }
Beispiel #5
0
 /// <summary>
 /// Converts an unparameterized command into a command parameterized by Unit.  This can be useful with methods such
 /// as Combine which expect particular types of commands that may not fit the command you have in order to
 /// get the behavor you otherwise expect.
 /// </summary>
 public static IRxFunction <Unit, TOutput> AsParameterized <TOutput>(this IRxFunction <TOutput> command)
 {
     return(RxFunction.CreateAsync <Unit, TOutput>(_ => command.InvokeAsync()));
 }
Beispiel #6
0
 /// <summary>
 /// Executes the command synchronously by directly returning Result on the async task.  This should generally only be
 /// called when you know the action will execute synchronously.  Otherwise you will likely face potential
 /// deadlocks.
 /// </summary>
 public static TOutput Invoke <TInput, TOutput>(this IRxFunction <TInput, TOutput> command, TInput input)
 {
     return(command.InvokeAsync(input).Result);
 }
Beispiel #7
0
 /// <summary>
 /// Executes the command synchronously by returning Result on the async task.  This should generally only be
 /// called when you know the action will execute synchronously.  Otherwise you will likely face potential
 /// deadlocks.
 /// </summary>
 public static TOutput Invoke <TOutput>(this IRxFunction <TOutput> command)
 {
     return(command.InvokeAsync().Result);
 }