Files
dotnet-bot adf899c629 Adding System.Data..., System.ServiceModel..., and System.Web...
Adding reference source for
System.Data
System.Data.DataSetExtensions
System.Data.Entity
System.Data.Entity.Design
System.Data.Linq
System.Data.SqlXml
System.ServiceModel
System.ServiceModel.Activation
System.ServiceModel.Activities
System.ServiceModel.Channels
System.ServiceModel.Discovery
System.ServiceModel.Internals
System.ServiceModel.Routing
System.ServiceModel.WasHosting
System.ServiceModel.Web
System.Web
System.Web.ApplicationServices
System.Web.DynamicData
System.Web.Entity
System.Web.Entity.Design
System.Web.Extensions
System.Web.Mobile
System.Web.Routing
System.Web.Services
System.Xml
System.Xml.Linq
2016-05-03 00:07:37 +02:00

84 lines
2.4 KiB
C#

//-----------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.ServiceModel.Dispatcher
{
using System;
using System.Collections.Generic;
using System.ServiceModel.Channels;
class SynchronizedChannelCollection<TChannel> : SynchronizedCollection<TChannel>
where TChannel : IChannel
{
EventHandler onChannelClosed;
EventHandler onChannelFaulted;
internal SynchronizedChannelCollection(object syncRoot)
: base(syncRoot)
{
this.onChannelClosed = new EventHandler(OnChannelClosed);
this.onChannelFaulted = new EventHandler(OnChannelFaulted);
}
void AddingChannel(TChannel channel)
{
channel.Faulted += this.onChannelFaulted;
channel.Closed += this.onChannelClosed;
}
void RemovingChannel(TChannel channel)
{
channel.Faulted -= this.onChannelFaulted;
channel.Closed -= this.onChannelClosed;
}
void OnChannelClosed(object sender, EventArgs args)
{
TChannel channel = (TChannel)sender;
this.Remove(channel);
}
void OnChannelFaulted(object sender, EventArgs args)
{
TChannel channel = (TChannel)sender;
this.Remove(channel);
}
protected override void ClearItems()
{
List<TChannel> items = this.Items;
for (int i = 0; i < items.Count; i++)
{
this.RemovingChannel(items[i]);
}
base.ClearItems();
}
protected override void InsertItem(int index, TChannel item)
{
this.AddingChannel(item);
base.InsertItem(index, item);
}
protected override void RemoveItem(int index)
{
TChannel oldItem = this.Items[index];
base.RemoveItem(index);
this.RemovingChannel(oldItem);
}
protected override void SetItem(int index, TChannel item)
{
TChannel oldItem = this.Items[index];
this.AddingChannel(item);
base.SetItem(index, item);
this.RemovingChannel(oldItem);
}
}
}