예제 #1
0
        /// <summary>
        /// oxana
        /// Returns a new instance for a client proxy over the specified interface with the specified config name used for initialization. And callback!!
        /// This instance of the proxy can be reused as it will always "clean" itself
        /// if the dual channel is faulted.
        /// The class will also unwrap any FaultException and throw the original Exception.
        /// </summary>
        public static TInterface GetReusableFaultUnwrappingInstance2(object callbackObject, string configName)
        {
            TInterface pooledInstance = ProxyConnectionPool.RequestFromPool <TInterface>();

            if (pooledInstance != null)
            {
                return(pooledInstance);
            }

            if (_reusableFaultUnwrappingInstance == null)
            {
                // no need to lock as the ProxyBuilder is thread safe and will always return the same stuff
                // Build the type
                _reusableFaultUnwrappingInstance = ProxyBuilder.BuildType <TInterface, WCFReusableFaultWrapperProxyClassBuilder <TInterface> >();
            }

            // Create new instance
            //TInterface instance = (TInterface)Activator.CreateInstance(_reusableFaultUnwrappingInstance, new object[] { (InstanceContext)callbackObject, configName });
            TInterface instance = (TInterface)Activator.CreateInstance(_reusableFaultUnwrappingInstance, new object[] { configName });

            //((DuplexClientRuntimeChannel)instance).CallbackInstance = callbackObject;



            ProxyConnectionPool.Register(instance);

            return(instance);
        }
예제 #2
0
        /// <summary>
        /// Returns a new instance for a client proxy over the specified interface with the specified config name used for initialization.
        /// This instance of the proxy can be reused as it will always "clean" itself
        /// if the channel is faulted.
        /// </summary>
        public static TInterface GetReusableInstance(string configName)
        {
            TInterface pooledInstance = ProxyConnectionPool.RequestFromPool <TInterface>();

            if (pooledInstance != null)
            {
                return(pooledInstance);
            }

            // Build the type
            Type type = ProxyBuilder.BuildType <TInterface, WCFReusableProxyClassBuilder <TInterface> >();

            // Create new instance
            TInterface instance = (TInterface)Activator.CreateInstance(type, new object[] { configName });

            ProxyConnectionPool.Register(instance);

            return(instance);
        }
예제 #3
0
        /// <summary>
        /// Returns a new instance for a client proxy over the specified interface with the specified config name used for initialization.
        /// This instance of the proxy can be reused as it will always "clean" itself
        /// if the channel is faulted.
        /// The class will also unwrap any FaultException and throw the original Exception.
        /// </summary>
        public static TInterface GetReusableFaultUnwrappingInstance(string configName)
        {
            TInterface pooledInstance = ProxyConnectionPool.RequestFromPool <TInterface>();

            if (pooledInstance != null)
            {
                return(pooledInstance);
            }

            if (_reusableFaultUnwrappingInstance == null)
            {
                // no need to lock as the ProxyBuilder is thread safe and will always return the same stuff
                // Build the type
                _reusableFaultUnwrappingInstance = ProxyBuilder.BuildType <TInterface, WCFReusableFaultWrapperProxyClassBuilder <TInterface> >();
            }

            // Create new instance
            TInterface instance = (TInterface)Activator.CreateInstance(_reusableFaultUnwrappingInstance, new object[] { configName });

            ProxyConnectionPool.Register(instance);

            return(instance);
        }