internal static T[] ToArray(SynchronizedCollection <T> collection) { lock (collection.SyncRoot) { return(EmptyArray <T> .ToArray((IList <T>) collection)); } }
public IChannel[] SnapshotChannels() { lock (base.ThisLock) { int num = (this.outgoingChannels != null) ? this.outgoingChannels.Count : 0; if (this.firstIncomingChannel != null) { IChannel[] array = new IChannel[1 + num]; array[0] = this.firstIncomingChannel; if (num > 0) { this.outgoingChannels.CopyTo(array, 1); } return(array); } if (this.incomingChannels != null) { IChannel[] channelArray2 = new IChannel[this.incomingChannels.Count + num]; this.incomingChannels.CopyTo(channelArray2, 0); if (num > 0) { this.outgoingChannels.CopyTo(channelArray2, this.incomingChannels.Count); } return(channelArray2); } if (num > 0) { IChannel[] channelArray3 = new IChannel[num]; this.outgoingChannels.CopyTo(channelArray3, 0); return(channelArray3); } } return(EmptyArray <IChannel> .Allocate(0)); }
public IChannel[] SnapshotChannels() { lock (this.ThisLock) { int outgoingCount = (this.outgoingChannels != null ? this.outgoingChannels.Count : 0); if (this.firstIncomingChannel != null) { IChannel[] channels = new IChannel[1 + outgoingCount]; channels[0] = this.firstIncomingChannel; if (outgoingCount > 0) { this.outgoingChannels.CopyTo(channels, 1); } return(channels); } if (this.incomingChannels != null) { IChannel[] channels = new IChannel[this.incomingChannels.Count + outgoingCount]; this.incomingChannels.CopyTo(channels, 0); if (outgoingCount > 0) { this.outgoingChannels.CopyTo(channels, this.incomingChannels.Count); } return(channels); } if (outgoingCount > 0) { IChannel[] channels = new IChannel[outgoingCount]; this.outgoingChannels.CopyTo(channels, 0); return(channels); } } return(EmptyArray <IChannel> .Allocate(0)); }