Table of Contents

FuncFactory<TTuple, TResult> Class

Definition

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

Provides a way of invoking an Func<TResult> delegate regardless of the amount of parameters provided.

public sealed class FuncFactory<TTuple, TResult> : MutableTupleFactory<TTuple> where TTuple : MutableTuple

Type Parameters

TTuple

The type of the n-tuple representation of a MutableTuple.

TResult

The type of the return value of the function delegate Cuemon.FuncFactory<TTuple, TResult>.Method.

Inheritance
FuncFactory<TTuple, TResult>
Inherited Members

Examples

The following example demonstrates how to use FuncFactory<TTuple, TResult> to encapsulate a function delegate and its arguments together for deferred execution.

using System;
using Cuemon;

namespace Contoso.Formatting;

public sealed class FuncFactoryExample
{
    public static void Run()
    {
        var factory = new FuncFactory<MutableTuple<string, int>, string>(
            tuple => $"{tuple.Arg1}-{tuple.Arg2:D3}",
            new MutableTuple<string, int>("Item", 7));

        string result = factory.ExecuteMethod();
        var clone = (FuncFactory<MutableTuple<string, int>, string>)factory.Clone();

        Console.WriteLine(result);
        Console.WriteLine(clone.ExecuteMethod());
    }
}

Constructors

Name Description
FuncFactory(Func<TTuple, TResult>, TTuple)

Initializes a new instance of the FuncFactory<TTuple, TResult> class.

FuncFactory(Func<TTuple, TResult>, TTuple, Delegate)

Initializes a new instance of the FuncFactory<TTuple, TResult> class.

Methods

Name Description
Clone()

Creates a shallow copy of the current FuncFactory<TTuple, TResult> object.

ExecuteMethod()

Executes the function delegate associated with this instance.