TesterFuncFactory<TTuple, TResult, TSuccess> Class
Definition
Provides a way of invoking an TesterFunc<TResult, TSuccess> function delegate regardless of the amount of parameters provided.
public class TesterFuncFactory<TTuple, TResult, TSuccess> : MutableTupleFactory<TTuple> where TTuple : MutableTuple
Type Parameters
TTupleThe type of the n-tuple representation of a MutableTuple.
TResultThe type of the out result value of the tester function delegate Method.
TSuccessThe type of the return value that indicates success of the tester function delegate Method.
- Inheritance
-
objectMutableTupleFactory<TTuple>TesterFuncFactory<TTuple, TResult, TSuccess>
- Inherited Members
Examples
The following example demonstrates how to use TesterFuncFactory<TArgs, TResult, TSuccess> to encapsulate a tester function with its arguments for deferred execution with output extraction.
using System;
using Cuemon;
namespace Contoso.Validation;
public sealed class TesterFuncFactoryExample
{
public static void Run()
{
var factory = new TesterFuncFactory<MutableTuple<int, int, int>, string, bool>(
(MutableTuple<int, int, int> tuple, out string result) =>
{
result = $"{tuple.Arg1},{tuple.Arg2},{tuple.Arg3}";
return true;
},
new MutableTuple<int, int, int>(1, 2, 3));
bool success = factory.ExecuteMethod(out string output);
var clone = (TesterFuncFactory<MutableTuple<int, int, int>, string, bool>)factory.Clone();
clone.ExecuteMethod(out string clonedOutput);
Console.WriteLine($"Success: {success}");
Console.WriteLine(output);
Console.WriteLine(clonedOutput);
}
}
Constructors
| Name | Description |
|---|---|
| TesterFuncFactory(TesterFunc<TTuple, TResult, TSuccess>, TTuple) | Initializes a new instance of the TesterFuncFactory<TTuple, TResult, TSuccess> class. |
| TesterFuncFactory(TesterFunc<TTuple, TResult, TSuccess>, TTuple, Delegate) | Initializes a new instance of the TesterFuncFactory<TTuple, TResult, TSuccess> class. |
Properties
| Name | Description |
|---|---|
| DelegateInfo | Gets the method represented by the tester function delegate. |
| HasDelegate | Gets a value indicating whether this instance has an assigned tester function delegate. |
| Method | Gets the tester function delegate to invoke. |
Methods
| Name | Description |
|---|---|
| Clone() | Creates a shallow copy of the current TesterFuncFactory<TTuple, TResult, TSuccess> object. |
| ExecuteMethod(out TResult) | Executes the tester function delegate associated with this instance. |