Beispiel #1
0
 /// <summary>
 /// 从接口生成代理类
 /// </summary>
 /// <typeparam name="TInterface">接口</typeparam>
 /// <typeparam name="TType">实现的类型</typeparam>
 /// <param name="parameters">构造函数的参数</param>
 /// <returns></returns>
 public static TInterface CreateProxyOfInterface <TInterface, TType>(object t1, object t2, object t3)
     where TInterface : class
     where TType : TInterface
 {
     ThrowHasConstructor(typeof(TType), new Type[] { t1.GetType(), t2.GetType(), t3.GetType() });
     return(DynamicProxy.CreateInterceptor <TInterface, TType>(new object[] { t1, t2, t3 }, false));
 }
Beispiel #2
0
 /// <summary>
 /// 从接口生成代理类
 /// </summary>
 /// <typeparam name="TInterface">接口</typeparam>
 /// <typeparam name="TType">实现的类型</typeparam>
 /// <param name="parameters">构造函数的参数</param>
 /// <returns></returns>
 public static TInterface CreateProxyOfInterface <TInterface, TType>(object[] parameters = null)
     where TInterface : class
     where TType : TInterface
 {
     ThrowHasConstructor(typeof(TType), parameters?.Select(x => x.GetType()).ToArray());
     return(DynamicProxy.CreateInterceptor <TInterface, TType>(parameters, false));
 }
Beispiel #3
0
 /// <summary>
 /// 通过指定 Type 来代理属性或方法
 /// <para>此方式可以实现非入侵性代理类型</para>
 /// </summary>
 /// <param name="builder"></param>
 /// <param name="propertys"></param>
 public static TType CreateProxyOfType <TType>(ProxyTypeBuilder builder, object[] parameters = null)
     where TType : class
 {
     ThrowHasConstructor(typeof(TType), parameters?.Select(x => x.GetType()).ToArray());
     return(DynamicProxy.CreateInterceptor <TType>(typeof(TType), builder.Build(), parameters));
 }
Beispiel #4
0
 /// <summary>
 /// 生成代理类型
 /// </summary>
 /// <typeparam name="TType">代理类型</typeparam>
 /// <param name="parameters">构造函数的参数</param>
 /// <returns>生成代理类</returns>
 public static TType CreateProxyOfClass <TType>(object[] parameters = null)
     where TType : class
 {
     ThrowHasConstructor(typeof(TType), parameters?.Select(x => x.GetType()).ToArray());
     return(DynamicProxy.CreateInterceptor <TType, TType>(parameters, true));
 }
Beispiel #5
0
 /// <summary>
 /// 生成代理类型
 /// </summary>
 /// <typeparam name="TType">代理类型</typeparam>
 /// <param name="parameters">构造函数的参数</param>
 /// <returns>生成代理类</returns>
 public static TType CreateProxyOfClass <TType>(object t1, object t2, object t3, object t4, object t5, object t6, object t7, object t8)
     where TType : class
 {
     ThrowHasConstructor(typeof(TType), new Type[] { t1.GetType(), t2.GetType(), t3.GetType(), t4.GetType(), t5.GetType(), t6.GetType(), t7.GetType(), t8.GetType() });
     return(DynamicProxy.CreateInterceptor <TType, TType>(new object[] { t1, t2, t3, t4, t5, t6, t7, t8 }, true));
 }
Beispiel #6
0
 /// <summary>
 /// 生成代理类型
 /// </summary>
 /// <typeparam name="TType">代理类型</typeparam>
 /// <param name="parameters">构造函数的参数</param>
 /// <returns>生成代理类</returns>
 public static TType CreateProxyOfClass <TType>(object t1, object t2)
     where TType : class
 {
     ThrowHasConstructor(typeof(TType), new Type[] { t1.GetType(), t2.GetType() });
     return(DynamicProxy.CreateInterceptor <TType, TType>(new object[] { t1, t2 }, true));
 }