mirror of https://github.com/Squidex/squidex.git
11 changed files with 177 additions and 232 deletions
@ -1,41 +0,0 @@ |
|||
// ==========================================================================
|
|||
// ActionContextDispatcherFactory.cs
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex Group
|
|||
// All rights reserved.
|
|||
// ==========================================================================
|
|||
|
|||
using System; |
|||
using System.Reflection; |
|||
|
|||
// ReSharper disable UnusedMember.Local
|
|||
|
|||
namespace Squidex.Infrastructure.Dispatching |
|||
{ |
|||
internal static class ActionContextDispatcherFactory |
|||
{ |
|||
public static Tuple<Type, Action<TTarget, object, TContext>> CreateActionHandler<TTarget, TContext>(MethodInfo methodInfo) |
|||
{ |
|||
var inputType = methodInfo.GetParameters()[0].ParameterType; |
|||
|
|||
var factoryMethod = |
|||
typeof(ActionContextDispatcherFactory) |
|||
.GetMethod("Factory", BindingFlags.Static | BindingFlags.NonPublic) |
|||
.MakeGenericMethod(typeof(TTarget), inputType, typeof(TContext)); |
|||
|
|||
var handler = factoryMethod.Invoke(null, new object[] { methodInfo }); |
|||
|
|||
return new Tuple<Type, Action<TTarget, object, TContext>>(inputType, (Action<TTarget, object, TContext>)handler); |
|||
} |
|||
|
|||
private static Action<TTarget, object, TContext> Factory<TTarget, TIn, TContext>(MethodInfo methodInfo) |
|||
{ |
|||
var type = typeof(Action<TTarget, TIn, TContext>); |
|||
|
|||
var handler = (Action<TTarget, TIn, TContext>)methodInfo.CreateDelegate(type); |
|||
|
|||
return (target, input, context) => handler(target, (TIn)input, context); |
|||
} |
|||
} |
|||
} |
|||
@ -1,41 +0,0 @@ |
|||
// ==========================================================================
|
|||
// ActionDispatcherFactory.cs
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex Group
|
|||
// All rights reserved.
|
|||
// ==========================================================================
|
|||
|
|||
using System; |
|||
using System.Reflection; |
|||
|
|||
// ReSharper disable UnusedMember.Local
|
|||
|
|||
namespace Squidex.Infrastructure.Dispatching |
|||
{ |
|||
internal static class ActionDispatcherFactory |
|||
{ |
|||
public static Tuple<Type, Action<T, object>> CreateActionHandler<T>(MethodInfo methodInfo) |
|||
{ |
|||
var inputType = methodInfo.GetParameters()[0].ParameterType; |
|||
|
|||
var factoryMethod = |
|||
typeof(ActionDispatcherFactory) |
|||
.GetMethod("Factory", BindingFlags.Static | BindingFlags.NonPublic) |
|||
.MakeGenericMethod(typeof(T), inputType); |
|||
|
|||
var handler = factoryMethod.Invoke(null, new object[] { methodInfo }); |
|||
|
|||
return new Tuple<Type, Action<T, object>>(inputType, (Action<T, object>)handler); |
|||
} |
|||
|
|||
private static Action<TTarget, object> Factory<TTarget, TIn>(MethodInfo methodInfo) |
|||
{ |
|||
var type = typeof(Action<TTarget, TIn>); |
|||
|
|||
var handler = (Action<TTarget, TIn>)methodInfo.CreateDelegate(type); |
|||
|
|||
return (target, input) => handler(target, (TIn)input); |
|||
} |
|||
} |
|||
} |
|||
@ -1,41 +0,0 @@ |
|||
// ==========================================================================
|
|||
// FuncContextDispatcherFactory.cs
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex Group
|
|||
// All rights reserved.
|
|||
// ==========================================================================
|
|||
|
|||
using System; |
|||
using System.Reflection; |
|||
|
|||
// ReSharper disable UnusedMember.Local
|
|||
|
|||
namespace Squidex.Infrastructure.Dispatching |
|||
{ |
|||
internal static class FuncContextDispatcherFactory |
|||
{ |
|||
public static Tuple<Type, Func<TTarget, object, TContext, TOut>> CreateFuncHandler<TTarget, TContext, TOut>(MethodInfo methodInfo) |
|||
{ |
|||
var inputType = methodInfo.GetParameters()[0].ParameterType; |
|||
|
|||
var factoryMethod = |
|||
typeof(FuncContextDispatcherFactory) |
|||
.GetMethod("Factory", BindingFlags.Static | BindingFlags.NonPublic) |
|||
.MakeGenericMethod(typeof(TTarget), inputType, typeof(TContext), methodInfo.ReturnType); |
|||
|
|||
var handler = factoryMethod.Invoke(null, new object[] { methodInfo }); |
|||
|
|||
return new Tuple<Type, Func<TTarget, object, TContext, TOut>>(inputType, (Func<TTarget, object, TContext, TOut>)handler); |
|||
} |
|||
|
|||
private static Func<TTarget, object, TContext, TOut> Factory<TTarget, TIn, TContext, TOut>(MethodInfo methodInfo) |
|||
{ |
|||
var type = typeof(Func<TTarget, TIn, TContext, TOut>); |
|||
|
|||
var handler = (Func<TTarget, TIn, TContext, TOut>)methodInfo.CreateDelegate(type); |
|||
|
|||
return (target, input, context) => handler(target, (TIn)input, context); |
|||
} |
|||
} |
|||
} |
|||
@ -1,41 +0,0 @@ |
|||
// ==========================================================================
|
|||
// FuncDispatcherFactory.cs
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex Group
|
|||
// All rights reserved.
|
|||
// ==========================================================================
|
|||
|
|||
using System; |
|||
using System.Reflection; |
|||
|
|||
// ReSharper disable once UnusedMember.Local
|
|||
|
|||
namespace Squidex.Infrastructure.Dispatching |
|||
{ |
|||
internal static class FuncDispatcherFactory |
|||
{ |
|||
public static Tuple<Type, Func<TTarget, object, TReturn>> CreateFuncHandler<TTarget, TReturn>(MethodInfo methodInfo) |
|||
{ |
|||
var inputType = methodInfo.GetParameters()[0].ParameterType; |
|||
|
|||
var factoryMethod = |
|||
typeof(FuncDispatcherFactory) |
|||
.GetMethod("Factory", BindingFlags.Static | BindingFlags.NonPublic) |
|||
.MakeGenericMethod(typeof(TTarget), inputType, methodInfo.ReturnType); |
|||
|
|||
var handler = factoryMethod.Invoke(null, new object[] { methodInfo }); |
|||
|
|||
return new Tuple<Type, Func<TTarget, object, TReturn>>(inputType, (Func<TTarget, object, TReturn>)handler); |
|||
} |
|||
|
|||
private static Func<TTarget, object, TReturn> Factory<TTarget, TIn, TReturn>(MethodInfo methodInfo) |
|||
{ |
|||
var type = typeof(Func<TTarget, TIn, TReturn>); |
|||
|
|||
var handler = (Func<TTarget, TIn, TReturn>)methodInfo.CreateDelegate(type); |
|||
|
|||
return (target, input) => handler(target, (TIn)input); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue