MethodAggregator 1.0.3
See the version list below for details.
dotnet add package MethodAggregator --version 1.0.3
NuGet\Install-Package MethodAggregator -Version 1.0.3
<PackageReference Include="MethodAggregator" Version="1.0.3" />
<PackageVersion Include="MethodAggregator" Version="1.0.3" />
<PackageReference Include="MethodAggregator" />
paket add MethodAggregator --version 1.0.3
#r "nuget: MethodAggregator, 1.0.3"
#:package MethodAggregator@1.0.3
#addin nuget:?package=MethodAggregator&version=1.0.3
#tool nuget:?package=MethodAggregator&version=1.0.3
MethodAggregator
MethodAggregator is a C# library that allows you to manage, register, and execute methods dynamically. It provides functionality to find and execute the most suitable method based on the provided parameters and return type.
Usage
How to use the Execute method:
using MethodAggregator;
public class Program
{
public static void Main(string[] args)
{
IMethodAggregator aggregator = new MethodAggregator();
// Register methods
aggregator.Register((Func<int, int, int>)Add);
aggregator.Register((Func<double, double, double>)Add);
// Execute methods
int intResult = aggregator.Execute<int>("Add", 1, 2);
double doubleResult = aggregator.Execute<double>("Add", 1.0, 2.0);
// Unregister methods
aggregator.Unregister((Func<int, int, int>)Add);
aggregator.Unregister((Func<double, double, double>)Add);
}
public static int Add(int a, int b)
{
return a + b;
}
public static double Add(double a, double b)
{
return a + b;
}
}
How to use the SimpleExecute method:
using MethodAggregator;
public class Program
{
public static void Main(string[] args)
{
IMethodAggregator aggregator = new MethodAggregator();
// Register methods
aggregator.Register((int x, int y) => x + y, "Add");
aggregator.Register((int x, double y) => x * y, "Multiply");
// Examples for SimpleExecute
int sumResult = aggregator.SimpleExecute<int>(10, 20); // Invokes the Add method
int multiplyResult = aggregator.SimpleExecute<int>(10, 5.5); // Invokes the Multiply method
Console.WriteLine($"Sum: {sumResult}");
Console.WriteLine($"Multiplication: {multiplyResult}");
}
}
Methods
The MethodAggregator class provides the following methods for managing and executing registered methods:
Execute<T>(string name, params object[] parameters): Executes the method with the specified name and parameters, returning a value of type TExecute(string name, params object[] parameters): Executes the method with the specified name and parameters, without returning a valueSimpleExecute<T>(params object[] parameters): Executes the method with the specified parameters, without specifying a name, and returns a value of type TSimpleExecute(params object[] parameters): Executes the method with the specified parameters, without specifying a name or returning a valueTryExecute<T>(out T returnValue, string name, params object[] parameters): Attempts to execute the method with the specified name and parameters, returning a value of type T, and returns a boolean indicating whether the operation succeededTryExecute(string name, params object[] parameters): Attempts to execute the method with the specified name and parameters, without returning a value, and returns a boolean indicating whether the operation succeededIsRegistered(Delegate del): Returns a boolean indicating whether the specified delegate is registered in the aggregatorRegister(Delegate del, string name = null): Registers the specified delegate with the given name, or the delegate's method name by defaultUnregister(Delegate del): Unregisters the specified delegate from the aggregatorDispose(): Releases all resources used by the MethodAggregator instance
Dependencies
JetBrains.Annotations
License
This project is licensed under the MIT License. See the LICENSE file for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- JetBrains.Annotations (>= 2022.3.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 2.0.1 | 256 | 9/18/2023 | |
| 2.0.0 | 350 | 5/11/2023 | |
| 1.0.5 | 339 | 5/11/2023 | |
| 1.0.4 | 372 | 5/11/2023 | |
| 1.0.4-ci.19 | 349 | 5/11/2023 | |
| 1.0.4-ci.18 | 359 | 5/4/2023 | |
| 1.0.4-ci.17 | 360 | 5/4/2023 | |
| 1.0.4-ci.16 | 355 | 5/4/2023 | |
| 1.0.4-ci.15 | 363 | 4/13/2023 | |
| 1.0.4-ci.14 | 364 | 4/9/2023 | |
| 1.0.4-ci.13 | 358 | 4/9/2023 | |
| 1.0.4-ci.12 | 358 | 4/9/2023 | |
| 1.0.4-ci.11 | 351 | 4/9/2023 | |
| 1.0.4-ci.10 | 368 | 4/9/2023 | |
| 1.0.4-ci.8 | 356 | 4/9/2023 | |
| 1.0.4-ci.7 | 360 | 4/9/2023 | |
| 1.0.4-ci.6 | 359 | 4/7/2023 | |
| 1.0.4-ci.5 | 371 | 4/5/2023 | |
| 1.0.4-ci.4 | 359 | 4/4/2023 | |
| 1.0.3 | 722 | 4/4/2023 |