Use delegates for custom serializers

This commit is contained in:
Simon Lübeß
2024-01-05 14:34:11 +01:00
parent a5e767df01
commit 9da675e4bb
4 changed files with 43 additions and 16 deletions
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
namespace GlitchyEngine.Extensions;
public static class MethodInfoExtension
{
/// <summary>
/// Gets the <see cref="Delegate"/> of this <see cref="MethodInfo"/>.
/// </summary>
/// <typeparam name="T">The type of the Delegate.</typeparam>
/// <param name="info">The method info.</param>
/// <returns>The delegate.</returns>
public static T GetDelegate<T>(this MethodInfo info) where T : Delegate
{
return (T)Delegate.CreateDelegate(typeof(T), info);
}
}