コード例 #1
0
        /// <summary>
        /// Closes the specified connections to the remote host and releases acquired resources.
        /// </summary>
        /// <param name="hostInformation">The host information.</param>
        /// <param name="genuineConnectionType">A value indicating what kind of connections will be affected by this operation.</param>
        /// <param name="reason">The reason of resource releasing.</param>
        public override void ReleaseConnections(HostInformation hostInformation, GenuineConnectionType genuineConnectionType, Exception reason)
        {
            BinaryLogWriter binaryLogWriter = this.ITransportContext.BinaryLogWriter;

            reason = GenuineExceptions.Get_Channel_ConnectionShutDown(reason);

            // LOG:
            if (binaryLogWriter != null && binaryLogWriter[LogCategory.Connection] > 0)
            {
                binaryLogWriter.WriteEvent(LogCategory.Connection, "SharedMemoryConnectionManager.ReleaseConnections",
                                           LogMessageType.ReleaseConnections, reason, null, hostInformation, null,
                                           GenuineUtility.CurrentThreadId, Thread.CurrentThread.Name,
                                           null, null, -1, 0, 0, 0, Enum.Format(typeof(GenuineConnectionType), genuineConnectionType, "g"), null, null, null,
                                           "Connections \"{0}\" will be terminated.", Enum.Format(typeof(GenuineConnectionType), genuineConnectionType, "g"), null);
            }

            if (hostInformation == null)
            {
                this.InternalDispose(reason);
                return;
            }

            SharedMemoryConnection sharedMemoryConnection = null;

            if (hostInformation.Url != null)
            {
                sharedMemoryConnection = this._persistent[hostInformation.Url] as SharedMemoryConnection;
            }
            if (sharedMemoryConnection != null)
            {
                this.ConnectionFailed(reason, sharedMemoryConnection);
            }

            sharedMemoryConnection = null;
            if (hostInformation.Uri != null)
            {
                sharedMemoryConnection = this._persistent[hostInformation.Uri] as SharedMemoryConnection;
            }
            if (sharedMemoryConnection != null)
            {
                this.ConnectionFailed(reason, sharedMemoryConnection);
            }
        }