Beispiel #1
0
        /// <summary>
        /// Performs the necessary actions to apply pooling behavior.
        /// </summary>
        /// <remarks>
        /// This method is invoked by the runtime.
        /// </remarks>
        public void ApplyDispatchBehavior(ServiceDescription description, ServiceHostBase serviceHostBase)
        {
            if (enabled)
            {
                // Create an instance of the ObjectPoolInstanceProvider.
                instanceProvider = new ObjectPoolInstanceProvider(description.ServiceType,
                                                                  maxPoolSize, minPoolSize, creationTimeout);

                // Assign our instance provider to Dispatch behavior in each
                // endpoint.
                foreach (ChannelDispatcherBase cdb in serviceHostBase.ChannelDispatchers)
                {
                    ChannelDispatcher cd = cdb as ChannelDispatcher;
                    if (cd != null)
                    {
                        foreach (EndpointDispatcher ed in cd.Endpoints)
                        {
                            ed.DispatchRuntime.InstanceProvider = instanceProvider;
                        }
                    }
                }
            }
        }
 public ObjectPoolingAttribute()
 {
     instanceProvider = null;
     enabled = true;
 }
        /// <summary>
        /// Performs the necessary actions to apply pooling behavior.
        /// </summary>        
        /// <remarks>
        /// This method is invoked by the runtime.
        /// </remarks>
        public void ApplyDispatchBehavior(ServiceDescription description, ServiceHostBase serviceHostBase)
        {
            if (enabled)
            {
                // Create an instance of the ObjectPoolInstanceProvider.
                instanceProvider = new ObjectPoolInstanceProvider(description.ServiceType,
                    maxPoolSize, minPoolSize, creationTimeout);

                // Assign our instance provider to Dispatch behavior in each 
                // endpoint.
                foreach (ChannelDispatcherBase cdb in serviceHostBase.ChannelDispatchers)
                {
                    ChannelDispatcher cd = cdb as ChannelDispatcher;
                    if (cd != null)
                    {
                        foreach (EndpointDispatcher ed in cd.Endpoints)
                        {
                            ed.DispatchRuntime.InstanceProvider = instanceProvider;
                        }
                    }
                }
            }
        }
Beispiel #4
0
 public ObjectPoolingAttribute()
 {
     instanceProvider = null;
     enabled          = true;
 }