Ejemplo n.º 1
0
        public void Dispose()
        {
            if (Interlocked.CompareExchange(ref disposed, 1, 0) == 1)
            {
                return;
            }

            var context = channel as IContextChannel;

            if (context != null)
            {
                foreach (var cleanUp in context.CleanUp())
                {
                    cleanUp.CleanUp();
                }
            }

            var parameters = channel.GetProperty <ChannelParameterCollection>();

            if (parameters != null)
            {
                foreach (var cleanUp in parameters.OfType <IWcfCleanUp>())
                {
                    cleanUp.CleanUp();
                }
            }

            if (channel != null)
            {
                WcfUtils.ReleaseCommunicationObject(channel, closeTimeout);
            }
        }
Ejemplo n.º 2
0
        public void Dispose()
        {
            var context = Channel as IContextChannel;

            if (context != null)
            {
                foreach (var cleanUp in context.Extensions.FindAll <IWcfCleanUp>())
                {
                    cleanUp.CleanUp();
                }
            }

            var parameters = Channel.GetProperty <ChannelParameterCollection>();

            if (parameters != null)
            {
                foreach (var cleanUp in parameters.OfType <IWcfCleanUp>())
                {
                    cleanUp.CleanUp();
                }
            }

            if (Channel != null)
            {
                WcfUtils.ReleaseCommunicationObject(Channel, CloseTimeout);
            }
        }
Ejemplo n.º 3
0
 private void ReleaseServiceHosts()
 {
     foreach (var serviceHost in hosts)
     {
         foreach (var cleanUp in serviceHost.Extensions.FindAll <IWcfCleanUp>())
         {
             cleanUp.CleanUp();
         }
         WcfUtils.ReleaseCommunicationObject(serviceHost, CloseTimeout);
     }
 }
Ejemplo n.º 4
0
        public void RefreshChannel()
        {
            if (Channel == null || IsChannelUsable == false)
            {
                if (Channel != null)
                {
                    WcfUtils.ReleaseCommunicationObject(Channel, CloseTimeout);
                }

                CreateChannel();
            }
        }
Ejemplo n.º 5
0
        private void Kernel_ComponentUnregistered(string key, IHandler handler)
        {
            var serviceHosts = handler.ComponentModel
                               .ExtendedProperties[WcfConstants.ServiceHostsKey] as IList <ServiceHost>;

            if (serviceHosts != null)
            {
                foreach (var serviceHost in serviceHosts)
                {
                    foreach (var cleanUp in serviceHost.Extensions.FindAll <IWcfCleanUp>())
                    {
                        cleanUp.CleanUp();
                    }
                    WcfUtils.ReleaseCommunicationObject(serviceHost, CloseTimeout);
                }
            }
        }
Ejemplo n.º 6
0
        public IChannel RefreshChannel(bool force)
        {
            if (disposed != 0)
            {
                return(channel);
            }

            if (force == false)
            {
                using (@lock.ForReading())
                {
                    if (IsChannelUsable())
                    {
                        return(channel);
                    }
                }
            }

            using (var locker = @lock.ForReadingUpgradeable())
            {
                if (force || IsChannelUsable() == false)
                {
                    locker.Upgrade();

                    var oldChannel = channel;
                    if (oldChannel != null)
                    {
                        WcfUtils.ReleaseCommunicationObject(oldChannel, closeTimeout);
                    }

                    CreateChannel();

                    NotifyChannelRefreshed(oldChannel, channel);
                }
                return(channel);
            }
        }