Exemplo n.º 1
0
        /// <summary>
        /// Returns the type of class that represents a proxy over the specified interface with the specified config name used for initialization.
        /// This is a simple instance of a ClientBase derived class.
        /// </summary>
        public static Type GetInstanceType()
        {
            // Build the type
            Type type = ProxyBuilder.BuildType <TInterface, WCFProxyClassBuilder <TInterface> >();

            return(type);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the instance.
        /// </summary>
        /// <param name="configName">Name of the configuration.</param>
        /// <returns>`0.</returns>
        protected T GetInstance(string configName)
        {
            T instance = ProxyConnectionPool.RequestFromPool <T>();

            if (instance != null)
            {
                _logger.Info("Returned pooled ProxyBase Instance {0} from configuration {1}.", instance.GetType(), configName);
                return(instance);
            }
            // Build the type
            Type type = ProxyBuilder.BuildType <T, WCFProxyClassBuilder <T> >();

            // Create new instance
            instance = (T)Activator.CreateInstance(type, new object[] { configName });
            ProxyConnectionPool.Register(instance);
            _logger.Info("Created New ProxyBase Instance {0} from configuration {1}", instance.GetType(), configName);
            return(instance);
        }
Exemplo n.º 4
0
        /// <summary>
        /// This instance of the proxy can be reused as it will always "clean" itself
        /// if the channel is faulted.
        /// </summary>
        /// <param name="configName">Name of the configuration.</param>
        /// <returns>TInterface.</returns>
        protected static T GetReusableInstance(string configName)
        {
            T instance = ProxyConnectionPool.RequestFromPool <T>();

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

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

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

            return(instance);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Gets the instance.
        /// </summary>
        /// <param name="binding">The binding.</param>
        /// <param name="endpoint">The endpoint.</param>
        /// <param name="credentials">The credentials.</param>
        /// <returns></returns>
        public static TInterface GetInstance(Binding binding, EndpointAddress endpoint, ClientCredentials credentials)
        {
            TInterface pooledInstance = ProxyConnectionPool.RequestFromPool <TInterface>();

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

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

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

            ProxyConnectionPool.Register(instance);

            return(instance);
        }
Exemplo n.º 7
0
        /// <summary>
        /// This instance of the proxy can be reused as it will always "clean" itself
        /// if the channel is faulted.
        /// </summary>
        /// <param name="binding">The binding.</param>
        /// <param name="endpoint">The endpoint.</param>
        /// <returns>TInterface.</returns>
        protected static T GetReusableInstance(Binding binding, EndpointAddress endpoint)
        {
            binding.Upscale();
            T instance = ProxyConnectionPool.RequestFromPool <T>();

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

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

            // Create new instance
            instance = (T)Activator.CreateInstance(type, new object[] { binding, endpoint });

            ProxyConnectionPool.Register(instance);

            return(instance);
        }
Exemplo n.º 8
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>
        /// <param name="binding">The binding.</param>
        /// <param name="endpoint">The endpoint.</param>
        /// <returns>TInterface.</returns>
        protected static T BuildReusableFaultUnwrappingInstance(Binding binding, EndpointAddress endpoint)
        {
            binding.Upscale();
            //TInterface instance = ProxyConnectionPool.RequestFromPool<TInterface>();
            //if (instance != null)
            //    return instance;

            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 <T, WCFReusableFaultWrapperProxyClassBuilder <T> >();
            }

            // Create new instance
            T instance = (T)Activator.CreateInstance(_reusableFaultUnwrappingInstance, new object[] { binding, endpoint });

            //ProxyConnectionPool.Register(instance);

            return(instance);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Gets the instance.
        /// </summary>
        /// <param name="binding">The binding.</param>
        /// <param name="endpoint">The endpoint.</param>
        /// <returns>TInterface.</returns>
        protected T GetInstance(Binding binding, EndpointAddress endpoint)
        {
            binding.Upscale();
            //FxLog<T>.DebugFormat("Upscaling binding {0}", binding);
            T instance = ProxyConnectionPool.RequestFromPool <T>();

            if (instance != null)
            {
                _logger.Info("Returned pooled ProxyBase Instance {0} from binding {1} on endpoint {2}.", instance.GetType(), binding, endpoint);
                return(instance);
            }
            // Build the type
            Type type = ProxyBuilder.BuildType <T, WCFProxyClassBuilder <T> >();

            //FxLog<T>.DebugFormat("Type {0} is build.", type);
            // Create new instance
            instance = (T)Activator.CreateInstance(type, new object[] { binding, endpoint });
            //FxLog<T>.DebugFormat("Instance {0} of type {1} is created.", instance, type);
            ProxyConnectionPool.Register(instance);
            _logger.Info("Created new ProxyBase Instance {0} from binding {1} on endpoint {2}.", instance.GetType(), binding, endpoint);
            return(instance);
        }
Exemplo n.º 10
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);
        }
Exemplo n.º 11
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>
        /// <param name="configName">Name of the configuration.</param>
        /// <returns>TInterface.</returns>
        protected T GetReusableFaultUnwrappingInstance(string configName)
        {
            T instance = ProxyConnectionPool.RequestFromPool <T>();

            if (instance != null)
            {
                _logger.Info("Returned pooled FaultUnWrapping ProxyBase Instance {0} from configuration {1}.", instance.GetType(), configName);
                return(instance);
            }

            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 <T, WCFReusableFaultWrapperProxyClassBuilder <T> >();
            }

            // Create new instance
            instance = (T)Activator.CreateInstance(_reusableFaultUnwrappingInstance, new object[] { configName });
            _logger.Info("Returned New FaultUnWrapping ProxyBase Instance {0} from configuration {1}.", instance, configName);
            ProxyConnectionPool.Register(instance);
            return(instance);
        }