ActionFactory Class
Definition
- Namespace
- Cuemon.Extensions
- Assemblies
- Cuemon.Extensions.Core.dll
Provides access to factory methods for creating ActionFactory<TTuple> instances that encapsulate a delegate with a variable amount of generic arguments.
public static class ActionFactory
- Inheritance
-
objectActionFactory
Examples
The following example demonstrates how to create an ActionFactory from a callback with arguments and execute it. It shows both creating a factory with Create and invoking directly with Invoke.
using System;
using Cuemon;
using Cuemon.Extensions;
namespace Cuemon.Extensions;
public class ActionFactoryExample
{
public void Demonstrate()
{
Action<string, int> callback = (name, count) =>
{
for (int i = 0; i < count; i++)
Console.WriteLine(name);
};
var factory = ActionFactory.Create(callback, "Loop", 3);
factory.ExecuteMethod();
ActionFactory.Invoke(tuple => Console.WriteLine(tuple.Arg1), MutableTupleFactory.CreateOne("Direct invoke"));
}
}