Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / CompMod / System / Diagnostics / TraceListeners.cs / 1 / TraceListeners.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
/*
*/
namespace System.Diagnostics {
using System;
using System.Collections;
using Microsoft.Win32;
///
/// Provides a thread-safe list of . A thread-safe list is synchronized.
///
public class TraceListenerCollection : IList {
ArrayList list;
internal TraceListenerCollection() {
list = new ArrayList(1);
}
///
/// Gets or sets the at
/// the specified index.
///
public TraceListener this[int i] {
get {
return (TraceListener)list[i];
}
set {
InitializeListener(value);
list[i] = value;
}
}
///
/// Gets the first in the list with the specified name.
///
public TraceListener this[string name] {
get {
foreach (TraceListener listener in this) {
if (listener.Name == name)
return listener;
}
return null;
}
}
///
///
/// Gets the number of listeners in the list.
///
///
public int Count {
get {
return list.Count;
}
}
///
/// Adds a to the list.
///
public int Add(TraceListener listener) {
InitializeListener(listener);
lock (TraceInternal.critSec) {
return list.Add(listener);
}
}
///
/// [To be supplied.]
///
public void AddRange(TraceListener[] value) {
if (value == null) {
throw new ArgumentNullException("value");
}
for (int i = 0; ((i) < (value.Length)); i = ((i) + (1))) {
this.Add(value[i]);
}
}
///
/// [To be supplied.]
///
public void AddRange(TraceListenerCollection value) {
if (value == null) {
throw new ArgumentNullException("value");
}
int currentCount = value.Count;
for (int i = 0; i < currentCount; i = ((i) + (1))) {
this.Add(value[i]);
}
}
///
///
/// Clears all the listeners from the
/// list.
///
///
public void Clear() {
list = new ArrayList();
}
///
/// Checks whether the list contains the specified
/// listener.
///
public bool Contains(TraceListener listener) {
return ((IList)this).Contains(listener);
}
///
/// Copies a section of the current list to the specified array at the specified
/// index.
///
public void CopyTo(TraceListener[] listeners, int index) {
((ICollection)this).CopyTo((Array) listeners, index);
}
///
///
/// Gets an enumerator for this list.
///
///
public IEnumerator GetEnumerator() {
return list.GetEnumerator();
}
internal void InitializeListener(TraceListener listener) {
if (listener == null)
throw new ArgumentNullException("listener");
listener.IndentSize = TraceInternal.IndentSize;
listener.IndentLevel = TraceInternal.IndentLevel;
}
///
/// Gets the index of the specified listener.
///
public int IndexOf(TraceListener listener) {
return ((IList)this).IndexOf(listener);
}
///
/// Inserts the listener at the specified index.
///
public void Insert(int index, TraceListener listener) {
InitializeListener(listener);
lock (TraceInternal.critSec) {
list.Insert(index, listener);
}
}
///
///
/// Removes the specified instance of the class from the list.
///
///
public void Remove(TraceListener listener) {
((IList)this).Remove(listener);
}
///
/// Removes the first listener in the list that has the
/// specified name.
///
public void Remove(string name) {
TraceListener listener = this[name];
if (listener != null)
((IList)this).Remove(listener);
}
///
/// Removes the at the specified index.
///
public void RemoveAt(int index) {
lock (TraceInternal.critSec) {
list.RemoveAt(index);
}
}
///
object IList.this[int index] {
get {
return list[index];
}
set {
TraceListener listener = value as TraceListener;
if (listener == null)
throw new ArgumentException(SR.GetString(SR.MustAddListener),"value");
InitializeListener(listener);
list[index] = listener;
}
}
///
bool IList.IsReadOnly {
get {
return false;
}
}
///
bool IList.IsFixedSize {
get {
return false;
}
}
///
int IList.Add(object value) {
TraceListener listener = value as TraceListener;
if (listener == null)
throw new ArgumentException(SR.GetString(SR.MustAddListener),"value");
InitializeListener(listener);
lock (TraceInternal.critSec) {
return list.Add(value);
}
}
///
bool IList.Contains(object value) {
return list.Contains(value);
}
///
int IList.IndexOf(object value) {
return list.IndexOf(value);
}
///
void IList.Insert(int index, object value) {
TraceListener listener = value as TraceListener;
if (listener == null)
throw new ArgumentException(SR.GetString(SR.MustAddListener),"value");
InitializeListener(listener);
lock (TraceInternal.critSec) {
list.Insert(index, value);
}
}
///
void IList.Remove(object value) {
lock (TraceInternal.critSec) {
list.Remove(value);
}
}
///
object ICollection.SyncRoot {
get {
return this;
}
}
///
bool ICollection.IsSynchronized {
get {
return true;
}
}
///
void ICollection.CopyTo(Array array, int index) {
lock (TraceInternal.critSec) {
list.CopyTo(array, index);
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
/*
*/
namespace System.Diagnostics {
using System;
using System.Collections;
using Microsoft.Win32;
///
/// Provides a thread-safe list of . A thread-safe list is synchronized.
///
public class TraceListenerCollection : IList {
ArrayList list;
internal TraceListenerCollection() {
list = new ArrayList(1);
}
///
/// Gets or sets the at
/// the specified index.
///
public TraceListener this[int i] {
get {
return (TraceListener)list[i];
}
set {
InitializeListener(value);
list[i] = value;
}
}
///
/// Gets the first in the list with the specified name.
///
public TraceListener this[string name] {
get {
foreach (TraceListener listener in this) {
if (listener.Name == name)
return listener;
}
return null;
}
}
///
///
/// Gets the number of listeners in the list.
///
///
public int Count {
get {
return list.Count;
}
}
///
/// Adds a to the list.
///
public int Add(TraceListener listener) {
InitializeListener(listener);
lock (TraceInternal.critSec) {
return list.Add(listener);
}
}
///
/// [To be supplied.]
///
public void AddRange(TraceListener[] value) {
if (value == null) {
throw new ArgumentNullException("value");
}
for (int i = 0; ((i) < (value.Length)); i = ((i) + (1))) {
this.Add(value[i]);
}
}
///
/// [To be supplied.]
///
public void AddRange(TraceListenerCollection value) {
if (value == null) {
throw new ArgumentNullException("value");
}
int currentCount = value.Count;
for (int i = 0; i < currentCount; i = ((i) + (1))) {
this.Add(value[i]);
}
}
///
///
/// Clears all the listeners from the
/// list.
///
///
public void Clear() {
list = new ArrayList();
}
///
/// Checks whether the list contains the specified
/// listener.
///
public bool Contains(TraceListener listener) {
return ((IList)this).Contains(listener);
}
///
/// Copies a section of the current list to the specified array at the specified
/// index.
///
public void CopyTo(TraceListener[] listeners, int index) {
((ICollection)this).CopyTo((Array) listeners, index);
}
///
///
/// Gets an enumerator for this list.
///
///
public IEnumerator GetEnumerator() {
return list.GetEnumerator();
}
internal void InitializeListener(TraceListener listener) {
if (listener == null)
throw new ArgumentNullException("listener");
listener.IndentSize = TraceInternal.IndentSize;
listener.IndentLevel = TraceInternal.IndentLevel;
}
///
/// Gets the index of the specified listener.
///
public int IndexOf(TraceListener listener) {
return ((IList)this).IndexOf(listener);
}
///
/// Inserts the listener at the specified index.
///
public void Insert(int index, TraceListener listener) {
InitializeListener(listener);
lock (TraceInternal.critSec) {
list.Insert(index, listener);
}
}
///
///
/// Removes the specified instance of the class from the list.
///
///
public void Remove(TraceListener listener) {
((IList)this).Remove(listener);
}
///
/// Removes the first listener in the list that has the
/// specified name.
///
public void Remove(string name) {
TraceListener listener = this[name];
if (listener != null)
((IList)this).Remove(listener);
}
///
/// Removes the at the specified index.
///
public void RemoveAt(int index) {
lock (TraceInternal.critSec) {
list.RemoveAt(index);
}
}
///
object IList.this[int index] {
get {
return list[index];
}
set {
TraceListener listener = value as TraceListener;
if (listener == null)
throw new ArgumentException(SR.GetString(SR.MustAddListener),"value");
InitializeListener(listener);
list[index] = listener;
}
}
///
bool IList.IsReadOnly {
get {
return false;
}
}
///
bool IList.IsFixedSize {
get {
return false;
}
}
///
int IList.Add(object value) {
TraceListener listener = value as TraceListener;
if (listener == null)
throw new ArgumentException(SR.GetString(SR.MustAddListener),"value");
InitializeListener(listener);
lock (TraceInternal.critSec) {
return list.Add(value);
}
}
///
bool IList.Contains(object value) {
return list.Contains(value);
}
///
int IList.IndexOf(object value) {
return list.IndexOf(value);
}
///
void IList.Insert(int index, object value) {
TraceListener listener = value as TraceListener;
if (listener == null)
throw new ArgumentException(SR.GetString(SR.MustAddListener),"value");
InitializeListener(listener);
lock (TraceInternal.critSec) {
list.Insert(index, value);
}
}
///
void IList.Remove(object value) {
lock (TraceInternal.critSec) {
list.Remove(value);
}
}
///
object ICollection.SyncRoot {
get {
return this;
}
}
///
bool ICollection.IsSynchronized {
get {
return true;
}
}
///
void ICollection.CopyTo(Array array, int index) {
lock (TraceInternal.critSec) {
list.CopyTo(array, index);
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SendKeys.cs
- SizeLimitedCache.cs
- CompositeControl.cs
- ReadWriteObjectLock.cs
- ProxyElement.cs
- InfoCardRSAOAEPKeyExchangeDeformatter.cs
- ConditionalAttribute.cs
- ListViewPagedDataSource.cs
- Component.cs
- LogicalCallContext.cs
- Helper.cs
- NetworkStream.cs
- DirectoryGroupQuery.cs
- ISAPIApplicationHost.cs
- MimeMultiPart.cs
- PassportAuthentication.cs
- FullTextBreakpoint.cs
- DateRangeEvent.cs
- ErrorReporting.cs
- TraceSource.cs
- WrappingXamlSchemaContext.cs
- RegexCompiler.cs
- ProxySimple.cs
- XAMLParseException.cs
- sqlser.cs
- Helpers.cs
- Knowncolors.cs
- SmtpClient.cs
- BamlRecordHelper.cs
- safex509handles.cs
- ModuleElement.cs
- DateTimeFormatInfoScanner.cs
- ServiceParser.cs
- DataColumn.cs
- DataGridAddNewRow.cs
- ParallelLoopState.cs
- CodeIterationStatement.cs
- DataGridViewSortCompareEventArgs.cs
- XamlTemplateSerializer.cs
- LoginName.cs
- SqlDependency.cs
- ArraySegment.cs
- HtmlShim.cs
- NaturalLanguageHyphenator.cs
- PrivilegeNotHeldException.cs
- XmlIlTypeHelper.cs
- HttpClientCredentialType.cs
- ProfilePropertyNameValidator.cs
- ParserContext.cs
- ZoneIdentityPermission.cs
- MatrixCamera.cs
- x509store.cs
- BuiltInExpr.cs
- ByteBufferPool.cs
- Double.cs
- _BasicClient.cs
- BezierSegment.cs
- LineUtil.cs
- Image.cs
- GenericPrincipal.cs
- XmlSchemaAnnotated.cs
- GridItemCollection.cs
- tooltip.cs
- RoutedEventHandlerInfo.cs
- TypeToken.cs
- HttpListenerPrefixCollection.cs
- InvalidPropValue.cs
- OlePropertyStructs.cs
- NetNamedPipeBinding.cs
- RenderTargetBitmap.cs
- ErrorInfoXmlDocument.cs
- ContractNamespaceAttribute.cs
- CodeConstructor.cs
- DataMemberConverter.cs
- WebBrowserEvent.cs
- TheQuery.cs
- DetailsView.cs
- MetricEntry.cs
- ExpressionBuilder.cs
- PerfCounterSection.cs
- MessageDroppedTraceRecord.cs
- RegexFCD.cs
- SqlUtil.cs
- InheritanceAttribute.cs
- LayoutDump.cs
- PrintEvent.cs
- HyperlinkAutomationPeer.cs
- PermissionSetTriple.cs
- OperationDescription.cs
- OraclePermission.cs
- ListViewTableCell.cs
- SizeAnimation.cs
- Stopwatch.cs
- BaseConfigurationRecord.cs
- MdiWindowListStrip.cs
- UrlMappingCollection.cs
- XmlMtomWriter.cs
- HttpCachePolicyElement.cs
- MembershipSection.cs
- CodeIndexerExpression.cs