コード例 #1
0
        private void CreateDisposableChannelProxy()
        {
            this.disposableChannelProxy = this.disposableServiceChannelProxyFactoryMethod.Invoke(this.serviceChannelFactoryMethod.Invoke());
            this.operations             = (TServiceInterface)this.disposableChannelProxy.GetTransparentProxy();

            // If these were not WeakEvents then they would cause the garbage collector to not collect this ServiceConsumer ;)
            this.disposableChannelProxy.ClosingChannelEvent.Subscribe(this.DisposableChannelProxy_ChannelNowUnusable);
            this.disposableChannelProxy.AbortingChannelEvent.Subscribe(this.DisposableChannelProxy_ChannelNowUnusable);
            this.disposableChannelProxy.DisposedChannelEvent.Subscribe(this.DisposableChannelProxy_ChannelNowUnusable);

            this.InitialiseExceptionStrategyInDisposableChannelProxy();
            this.InitialiseChannelCloseTriggerStrategyInDisposableChannelProxy();
        }
コード例 #2
0
        private void DisposeDisposableChannelProxy()
        {
            try
            {
                if (this.disposableChannelProxy != null)
                {
                    this.disposableChannelProxy.ClosingChannelEvent.Unsubscribe(this.DisposableChannelProxy_ChannelNowUnusable);
                    this.disposableChannelProxy.AbortingChannelEvent.Unsubscribe(this.DisposableChannelProxy_ChannelNowUnusable);
                    this.disposableChannelProxy.DisposedChannelEvent.Unsubscribe(this.DisposableChannelProxy_ChannelNowUnusable);

                    this.disposableChannelProxy.Dispose();
                }
            }
            finally
            {
                this.disposableChannelProxy = null;
                this.operations             = default(TServiceInterface);
            }
        }