目录
1.3 /// Create a proxy with provided target
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using Flatwhite.Core.Provider;
namespace Flatwhite.Core
{
/// <summary>
/// </summary>
public class MethodInterceptor<T> : DispatchProxy where T : class
{
private static readonly MethodInfo HandleAsyncWithTypeMethod = typeof (MethodInterceptor<T>).GetMethod(nameof(HandleAsyncWithType), BindingFlags.Instance | BindingFlags.NonPublic);
private T _decorated;
private IAttributeProvider _attributeProvider;
private IContextProvider _contextProvider;
/// <summary>
/// </summary>
/// <param name="decorated"></param>
/// <param name="contextProvider"></param>
/// <param name="attributeProvider"></param>
/// <returns></returns>
public static T Create(T decorated, IContextProvider contextProvider, IAttributeProvider attributeProvider)
{
object proxy = Create<T, MethodInterceptor<T>>();
((MethodInterceptor<T>) proxy).SetParameters(decorated, contextProvider, attributeProvider);
return (T) proxy;
}