refactor: renamed DelegateHelpers to DelegateExtensions

This commit is contained in:
2025-05-04 18:52:47 +03:00
parent fbbdfb07fa
commit 41c5def097

View File

@@ -0,0 +1,17 @@
using System;
namespace Syntriax.Engine.Core;
public static class DelegateExtensions
{
public static void InvokeSafe(this Delegate @delegate, params object?[] args)
{
foreach (Delegate invocation in @delegate.GetInvocationList())
try { invocation.DynamicInvoke(args); }
catch (Exception exception)
{
string methodCallRepresentation = $"{invocation.Method.DeclaringType?.FullName}.{invocation.Method.Name}({string.Join(", ", args)})";
Console.WriteLine($"Unexpected exception on invocation of method {methodCallRepresentation}:{Environment.NewLine}{exception.InnerException}");
}
}
}