Table of Contents

FuncFactory Class

Definition

Namespace
Cuemon.Extensions
Assemblies
Cuemon.Extensions.Core.dll
Source
src/Cuemon.Extensions.Core/FuncFactory.cs

Provides access to factory methods for creating FuncFactory<TTuple, TResult> instances that encapsulate a function delegate with a variable amount of generic arguments.

public static class FuncFactory
Inheritance
object
FuncFactory

Examples

The following example demonstrates how to create a FuncFactory from a delegate and execute it to produce a result. It shows both creating a factory with Create and invoking directly with Invoke using a mutable tuple.

using System;
using Cuemon;
using Cuemon.Extensions;

namespace Cuemon.Extensions;

public class FuncFactoryExample
{
    public void Demonstrate()
    {
        Func<int, int, string> formatter = (x, y) => $"{x} + {y} = {x + y}";

        var factory = FuncFactory.Create(formatter, 3, 4);
        string result = factory.ExecuteMethod();

        Console.WriteLine(result);

        int sum = FuncFactory.Invoke<MutableTuple<int, int>, int>(tuple => tuple.Arg1 + tuple.Arg2, MutableTupleFactory.CreateTwo(10, 20));
        Console.WriteLine(sum);
    }
}

Methods

Name Description
Create<TResult>(Func<TResult>)

Creates a new FuncFactory<TTuple, TResult> instance encapsulating the specified method.

Create<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult>(Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult>, T1, T2, T3, T4, T5, T6, T7, T8, T9)

Creates a new FuncFactory<TTuple, TResult> instance encapsulating the specified method and nine generic arguments.

Create<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult>(Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult>, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)

Creates a new FuncFactory<TTuple, TResult> instance encapsulating the specified method and ten generic arguments.

Create<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult>(Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult>, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)

Creates a new FuncFactory<TTuple, TResult> instance encapsulating the specified method and eleven generic arguments.

Create<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult>(Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult>, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)

Creates a new FuncFactory<TTuple, TResult> instance encapsulating the specified method and twelfth generic arguments.

Create<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TResult>(Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TResult>, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)

Creates a new FuncFactory<TTuple, TResult> instance encapsulating the specified method and thirteen generic arguments.

Create<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TResult>(Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TResult>, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14)

Creates a new FuncFactory<TTuple, TResult> instance encapsulating the specified method and fourteen generic arguments.

Create<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TResult>(Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TResult>, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)

Creates a new FuncFactory<TTuple, TResult> instance encapsulating the specified method and fifteen generic arguments.

Create<T, TResult>(Func<T, TResult>, T)

Creates a new FuncFactory<TTuple, TResult> instance encapsulating the specified method and one generic argument.

Create<T1, T2, TResult>(Func<T1, T2, TResult>, T1, T2)

Creates a new FuncFactory<TTuple, TResult> instance encapsulating the specified method and two generic arguments.

Create<T1, T2, T3, TResult>(Func<T1, T2, T3, TResult>, T1, T2, T3)

Creates a new FuncFactory<TTuple, TResult> instance encapsulating the specified method and three generic arguments.

Create<T1, T2, T3, T4, TResult>(Func<T1, T2, T3, T4, TResult>, T1, T2, T3, T4)

Creates a new FuncFactory<TTuple, TResult> instance encapsulating the specified method and four generic arguments.

Create<T1, T2, T3, T4, T5, TResult>(Func<T1, T2, T3, T4, T5, TResult>, T1, T2, T3, T4, T5)

Creates a new FuncFactory<TTuple, TResult> instance encapsulating the specified method and five generic arguments.

Create<T1, T2, T3, T4, T5, T6, TResult>(Func<T1, T2, T3, T4, T5, T6, TResult>, T1, T2, T3, T4, T5, T6)

Creates a new FuncFactory<TTuple, TResult> instance encapsulating the specified method and six generic arguments.

Create<T1, T2, T3, T4, T5, T6, T7, TResult>(Func<T1, T2, T3, T4, T5, T6, T7, TResult>, T1, T2, T3, T4, T5, T6, T7)

Creates a new FuncFactory<TTuple, TResult> instance encapsulating the specified method and seven generic arguments.

Create<T1, T2, T3, T4, T5, T6, T7, T8, TResult>(Func<T1, T2, T3, T4, T5, T6, T7, T8, TResult>, T1, T2, T3, T4, T5, T6, T7, T8)

Creates a new FuncFactory<TTuple, TResult> instance encapsulating the specified method and eight generic arguments.

Invoke<TTuple, TResult>(Func<TTuple, TResult>, TTuple)

Invokes the specified delegate method with a n-tuple argument.