public static IProxy CreateProxy(this Type type, IInvokeWrapper wrapper, params Type[] baseInterfaces)
 {
     Type proxyType = _factory.CreateProxyType(type, baseInterfaces);
     IProxy result = (IProxy)Activator.CreateInstance(proxyType);
     result.Interceptor = new CallAdapter(wrapper);
     return result;
 }
예제 #2
0
        /// <summary>
        /// Uses the <paramref name="factory"/> to create a proxy instance
        /// that directly derives from the <paramref name="instanceType"/>
        /// and implements the given <paramref name="baseInterfaces"/>.
        /// The <paramref name="wrapper"/> instance, in turn, will be used
        /// to intercept the method calls made to the proxy itself.
        /// </summary>
        /// <param name="factory">The IProxyFactory instance that will be used to generate the proxy type.</param>
        /// <param name="instanceType">The type that will be intercepted by the proxy.</param>
        /// <param name="wrapper">The <see cref="IInvokeWrapper"/> instance that will be used to intercept method calls made to the proxy.</param>
        /// <param name="baseInterfaces">The additional list of interfaces that the proxy will implement.</param>
        /// <returns>A valid proxy instance.</returns>
        public static object CreateProxy(this IProxyFactory factory, Type instanceType,
                                         IInvokeWrapper wrapper, params Type[] baseInterfaces)
        {
            // Convert the wrapper to an IInterceptor instance.
            var adapter = new CallAdapter(wrapper);

            return(factory.CreateProxy(instanceType, adapter, baseInterfaces));
        }
예제 #3
0
        public static IProxy CreateProxy(this Type type, IInvokeWrapper wrapper, params Type[] baseInterfaces)
        {
            Type   proxyType = _factory.CreateProxyType(type, baseInterfaces);
            IProxy result    = (IProxy)Activator.CreateInstance(proxyType);

            result.Interceptor = new CallAdapter(wrapper);
            return(result);
        }
예제 #4
0
 /// <summary>
 ///     Initializes the CallAdapter class with the <paramref name="wrapper" /> instance.
 /// </summary>
 /// <param name="wrapper">
 ///     The <see cref="IInvokeWrapper" /> instance that will be called every time the interceptor is
 ///     invoked.
 /// </param>
 public CallAdapter(IInvokeWrapper wrapper)
 {
     _wrapper = wrapper;
 }
예제 #5
0
 /// <summary>
 /// Uses the <paramref name="factory"/> to create a proxy instance
 /// that directly derives from the <typeparamref name="T"/> type
 /// and implements the given <paramref name="baseInterfaces"/>.
 /// The <paramref name="wrapper"/> instance, in turn, will be used
 /// to intercept the method calls made to the proxy itself.
 /// </summary>
 /// <typeparam name="T">The type that will be intercepted by the proxy.</typeparam>
 /// <param name="factory">The IProxyFactory instance that will be used to generate the proxy type.</param>
 /// <param name="wrapper">The <see cref="IInvokeWrapper"/> instance that will be used to intercept method calls made to the proxy.</param>
 /// <param name="baseInterfaces">The additional list of interfaces that the proxy will implement.</param>
 /// <returns>A valid proxy instance.</returns>
 public static T CreateProxy <T>(this IProxyFactory factory, IInvokeWrapper wrapper,
                                 params Type[] baseInterfaces)
 {
     return((T)factory.CreateProxy(typeof(T), wrapper, baseInterfaces));
 }
예제 #6
0
 /// <summary>
 /// Initializes the CallAdapter class with the <paramref name="wrapper"/> instance.
 /// </summary>
 /// <param name="wrapper">The <see cref="IInvokeWrapper"/> instance that will be called every time the interceptor is invoked.</param>
 public CallAdapter(IInvokeWrapper wrapper)
 {
     _wrapper = wrapper;
 }
예제 #7
0
 public virtual T CreateProxy <T>(IInvokeWrapper wrapper, params Type[] baseInterfaces)
 {
     return(CreateProxy <T>(new CallAdapter(wrapper), baseInterfaces));
 }
예제 #8
0
 public virtual object CreateProxy(Type instanceType, IInvokeWrapper wrapper, params Type[] baseInterfaces)
 {
     return(CreateProxy(instanceType, new CallAdapter(wrapper), baseInterfaces));
 }