Esempio n. 1
0
 public WcfAsyncProxy(object service, Func <MethodInfo, WcfAsyncMethodsHolder> getAsyncMethods,
                      WcfAsyncProxyConfiguration configuration)
 {
     _service         = service;
     _getAsyncMethods = getAsyncMethods;
     _configuration   = configuration;
 }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <c>WcfAsyncProxyCreator</c> class
        /// </summary>
        /// <param name="configuration">Extended configuration</param>
        public WcfAsyncProxyCreator(WcfAsyncProxyConfiguration configuration)
        {
            WcfAsyncProxyCache.GetAsyncInterface(
                typeof(TInterface), out _asyncInterfaceType, out _methodInfoToAsyncFunc);

            var genericFactoryType = typeof(ChannelFactory <>);
            var factoryType        = genericFactoryType.MakeGenericType(_asyncInterfaceType);      // here we have async interface!

            if (configuration.RemoteAddress != null && configuration.Binding != null)
            {
                _channelFactory = Activator.CreateInstance(factoryType, new object[] { configuration.Binding, configuration.RemoteAddress });
            }
            else if (configuration.RemoteAddress != null && configuration.Binding == null)
            {
                _channelFactory = Activator.CreateInstance(factoryType, new object[] { configuration.EndpointConfigurationName, configuration.RemoteAddress });
            }
            else
            {
                _channelFactory = Activator.CreateInstance(factoryType, new object[] { configuration.EndpointConfigurationName });
            }

            _configuration  = (WcfAsyncProxyConfiguration)configuration.Clone();
            _channelCreator = factoryType.GetMethod("CreateChannel", new Type[] { });
        }