/// <summary> /// Unregisters the proxy. /// </summary> /// <param name="proxy">The proxy.</param> internal static void UnregisterProxy(ProxyBase proxy) { if (proxy == null) { ThrowHelper.ThrowArgumentNullException("proxy"); } lock (mContractAndInstancePerSessionAndChannel) { IEnumeratorSpecialized <ContractAndInstanceStruct> iterator = mContractAndInstancePerSessionAndChannel.GetEnumerator(); while (iterator.MoveNext()) { ContractAndInstanceStruct s = iterator.Current; if (s.Instance.Equals(proxy)) { iterator.Remove(); break; } } } }
private void ChannelSessionStateChangeEventHandler(object sender, SessionStateEventArgs e) { // PerSession módban a session-höz tartozó implementációkat meg kell szüntetni if (!e.IsConnected) { Channel channel = (Channel)sender; lock (mContractAndInstancePerSessionAndChannel) { IEnumeratorSpecialized <ContractAndInstanceStruct> iterator = mContractAndInstancePerSessionAndChannel.GetEnumerator(); while (iterator.MoveNext()) { ContractAndInstanceStruct s = iterator.Current; if (s.Channel.Equals(channel) && s.SessionId.Equals(e.SessionId)) { iterator.Remove(); s.Instance.Dispose(); } } } } }
/// <summary> /// Channels the unregistered event handler. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="Forge.Net.Remoting.Channels.ChannelRegistrationEventArgs"/> instance containing the event data.</param> protected override void ChannelUnregisteredEventHandler(object sender, ChannelRegistrationEventArgs e) { base.ChannelUnregisteredEventHandler(sender, e); Channel channel = e.Channel; // leiratkozom az eseményről channel.SessionStateChange -= new EventHandler <SessionStateEventArgs>(ChannelSessionStateChangeEventHandler); // megszüntetem a channel-hez tartozó PerSession ProxyBase instance-okat lock (mContractAndInstancePerSessionAndChannel) { IEnumeratorSpecialized <ContractAndInstanceStruct> iterator = mContractAndInstancePerSessionAndChannel.GetEnumerator(); while (iterator.MoveNext()) { ContractAndInstanceStruct s = iterator.Current; if (s.Channel.Equals(channel)) { iterator.Remove(); s.Instance.Dispose(); } } } // konfiguráció adminisztrációja, törlöm a csatornához köthető információkat List <ContractServiceSideDescriptor> list = new List <ContractServiceSideDescriptor>(); lock (mContractDescriptors) { list.AddRange(mContractDescriptors.Values); } foreach (ContractServiceSideDescriptor ss in list) { lock (ss) { ss.ImplementationPerChannel.Remove(channel.ChannelId); } } list.Clear(); }