Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / clr / src / BCL / System / Diagnostics / LogSwitch.cs / 1 / LogSwitch.cs
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
namespace System.Diagnostics {
using System;
using System.IO;
using System.Collections;
[Serializable()]
internal class LogSwitch
{
// ! WARNING !
// If any fields are added/deleted/modified, perform the
// same in the EE code (debugdebugger.cpp)
internal String strName;
internal String strDescription;
private LogSwitch ParentSwitch;
private LogSwitch[] ChildSwitch;
internal LoggingLevels iLevel;
internal LoggingLevels iOldLevel;
private int iNumChildren;
private int iChildArraySize;
// ! END WARNING !
private LogSwitch ()
{
}
// Constructs a LogSwitch. A LogSwitch is used to categorize log messages.
//
// All switches (except for the global LogSwitch) have a parent LogSwitch.
//
public LogSwitch(String name, String description, LogSwitch parent)
{
if ((name != null) && (parent != null) )
{
if (name.Length == 0)
throw new ArgumentOutOfRangeException ("Name", Environment.GetResourceString("Argument_StringZeroLength"));
strName = name;
strDescription = description;
iLevel = LoggingLevels.ErrorLevel;
iOldLevel = iLevel;
// update the parent switch to reflect this child switch
parent.AddChildSwitch (this);
ParentSwitch = parent;
ChildSwitch = null;
iNumChildren = 0;
iChildArraySize = 0;
Log.m_Hashtable.Add (strName, this);
// Call into the EE to let it know about the creation of
// this switch
Log.AddLogSwitch (this);
// update switch count
Log.iNumOfSwitches++;
}
else
throw new ArgumentNullException ((name==null ? "name" : "parent"));
}
internal LogSwitch(String name, String description)
{
strName = name;
strDescription = description;
iLevel = LoggingLevels.ErrorLevel;
iOldLevel = iLevel;
ParentSwitch = null;
ChildSwitch = null;
iNumChildren = 0;
iChildArraySize = 0;
Log.m_Hashtable.Add (strName, this);
// Call into the EE to let it know about the creation of
// this switch
Log.AddLogSwitch (this);
// update switch count
Log.iNumOfSwitches++;
}
// Get property returns the name of the switch
public virtual String Name
{
get { return strName;}
}
// Get property returns the description of the switch
public virtual String Description
{
get {return strDescription;}
}
// Get property returns the parent of the switch
public virtual LogSwitch Parent
{
get { return ParentSwitch; }
}
// Property to Get/Set the level of log messages which are "on" for the switch.
//
public virtual LoggingLevels MinimumLevel
{
get { return iLevel; }
set
{
iLevel = value;
iOldLevel = value;
String strParentName = ParentSwitch!=null ? ParentSwitch.Name : "";
if (Debugger.IsAttached)
Log.ModifyLogSwitch ((int)iLevel, strName, strParentName);
Log.InvokeLogSwitchLevelHandlers (this, iLevel);
}
}
// Checks if the given level is "on" for this switch or one of its parents.
//
public virtual bool CheckLevel(LoggingLevels level)
{
if (iLevel > level)
{
// recurse through the list till parent is hit.
if (this.ParentSwitch == null)
return false;
else
return this.ParentSwitch.CheckLevel (level);
}
else
return true;
}
// Returns a switch with the particular name, if any. Returns null if no
// such switch exists.
public static LogSwitch GetSwitch(String name)
{
return (LogSwitch) Log.m_Hashtable[name];
}
private void AddChildSwitch (LogSwitch child)
{
if (iChildArraySize <= iNumChildren)
{
int iIncreasedSize;
if (iChildArraySize == 0)
iIncreasedSize = 10;
else
iIncreasedSize = (iChildArraySize * 3) / 2;
// increase child array size in chunks of 4
LogSwitch[] newChildSwitchArray = new LogSwitch [iIncreasedSize];
// copy the old array objects into the new one.
if (iNumChildren > 0)
Array.Copy(ChildSwitch, newChildSwitchArray, iNumChildren);
iChildArraySize = iIncreasedSize;
ChildSwitch = newChildSwitchArray;
}
ChildSwitch [iNumChildren++] = child;
}
}
}
// 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.IO;
using System.Collections;
[Serializable()]
internal class LogSwitch
{
// ! WARNING !
// If any fields are added/deleted/modified, perform the
// same in the EE code (debugdebugger.cpp)
internal String strName;
internal String strDescription;
private LogSwitch ParentSwitch;
private LogSwitch[] ChildSwitch;
internal LoggingLevels iLevel;
internal LoggingLevels iOldLevel;
private int iNumChildren;
private int iChildArraySize;
// ! END WARNING !
private LogSwitch ()
{
}
// Constructs a LogSwitch. A LogSwitch is used to categorize log messages.
//
// All switches (except for the global LogSwitch) have a parent LogSwitch.
//
public LogSwitch(String name, String description, LogSwitch parent)
{
if ((name != null) && (parent != null) )
{
if (name.Length == 0)
throw new ArgumentOutOfRangeException ("Name", Environment.GetResourceString("Argument_StringZeroLength"));
strName = name;
strDescription = description;
iLevel = LoggingLevels.ErrorLevel;
iOldLevel = iLevel;
// update the parent switch to reflect this child switch
parent.AddChildSwitch (this);
ParentSwitch = parent;
ChildSwitch = null;
iNumChildren = 0;
iChildArraySize = 0;
Log.m_Hashtable.Add (strName, this);
// Call into the EE to let it know about the creation of
// this switch
Log.AddLogSwitch (this);
// update switch count
Log.iNumOfSwitches++;
}
else
throw new ArgumentNullException ((name==null ? "name" : "parent"));
}
internal LogSwitch(String name, String description)
{
strName = name;
strDescription = description;
iLevel = LoggingLevels.ErrorLevel;
iOldLevel = iLevel;
ParentSwitch = null;
ChildSwitch = null;
iNumChildren = 0;
iChildArraySize = 0;
Log.m_Hashtable.Add (strName, this);
// Call into the EE to let it know about the creation of
// this switch
Log.AddLogSwitch (this);
// update switch count
Log.iNumOfSwitches++;
}
// Get property returns the name of the switch
public virtual String Name
{
get { return strName;}
}
// Get property returns the description of the switch
public virtual String Description
{
get {return strDescription;}
}
// Get property returns the parent of the switch
public virtual LogSwitch Parent
{
get { return ParentSwitch; }
}
// Property to Get/Set the level of log messages which are "on" for the switch.
//
public virtual LoggingLevels MinimumLevel
{
get { return iLevel; }
set
{
iLevel = value;
iOldLevel = value;
String strParentName = ParentSwitch!=null ? ParentSwitch.Name : "";
if (Debugger.IsAttached)
Log.ModifyLogSwitch ((int)iLevel, strName, strParentName);
Log.InvokeLogSwitchLevelHandlers (this, iLevel);
}
}
// Checks if the given level is "on" for this switch or one of its parents.
//
public virtual bool CheckLevel(LoggingLevels level)
{
if (iLevel > level)
{
// recurse through the list till parent is hit.
if (this.ParentSwitch == null)
return false;
else
return this.ParentSwitch.CheckLevel (level);
}
else
return true;
}
// Returns a switch with the particular name, if any. Returns null if no
// such switch exists.
public static LogSwitch GetSwitch(String name)
{
return (LogSwitch) Log.m_Hashtable[name];
}
private void AddChildSwitch (LogSwitch child)
{
if (iChildArraySize <= iNumChildren)
{
int iIncreasedSize;
if (iChildArraySize == 0)
iIncreasedSize = 10;
else
iIncreasedSize = (iChildArraySize * 3) / 2;
// increase child array size in chunks of 4
LogSwitch[] newChildSwitchArray = new LogSwitch [iIncreasedSize];
// copy the old array objects into the new one.
if (iNumChildren > 0)
Array.Copy(ChildSwitch, newChildSwitchArray, iNumChildren);
iChildArraySize = iIncreasedSize;
ChildSwitch = newChildSwitchArray;
}
ChildSwitch [iNumChildren++] = child;
}
}
}
// 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
- SettingsPropertyValueCollection.cs
- Int64Storage.cs
- StoreContentChangedEventArgs.cs
- ListViewVirtualItemsSelectionRangeChangedEvent.cs
- XmlSchemaInferenceException.cs
- TemplateParser.cs
- ContainerActivationHelper.cs
- NumberSubstitution.cs
- X509Certificate2Collection.cs
- sqlcontext.cs
- WhitespaceSignificantCollectionAttribute.cs
- EntityDataSourceEntityTypeFilterConverter.cs
- SQLBinaryStorage.cs
- ReadOnlyDictionary.cs
- ConnectionPoolManager.cs
- GeneralTransform3DGroup.cs
- SQLBytes.cs
- updateconfighost.cs
- DataTableClearEvent.cs
- IListConverters.cs
- ScrollItemProviderWrapper.cs
- NativeMethods.cs
- ThicknessAnimationBase.cs
- HttpProtocolReflector.cs
- WebControlsSection.cs
- Classification.cs
- FieldAccessException.cs
- TransactionManager.cs
- RegexNode.cs
- TokenBasedSet.cs
- Trigger.cs
- PanelDesigner.cs
- BitmapEffectCollection.cs
- TextCollapsingProperties.cs
- BinaryConverter.cs
- PropertyOrder.cs
- ContextMenuStripActionList.cs
- OracleMonthSpan.cs
- ActivityStateRecord.cs
- XslAstAnalyzer.cs
- ApplicationDirectory.cs
- CodeNamespaceCollection.cs
- TextTreeFixupNode.cs
- WebPartChrome.cs
- AnimatedTypeHelpers.cs
- errorpatternmatcher.cs
- FixedTextSelectionProcessor.cs
- PeerValidationBehavior.cs
- CommonObjectSecurity.cs
- GC.cs
- MappedMetaModel.cs
- TimersDescriptionAttribute.cs
- ByteStreamMessageEncoderFactory.cs
- Ops.cs
- ListViewSortEventArgs.cs
- ACE.cs
- PerfCounterSection.cs
- LongTypeConverter.cs
- StaticResourceExtension.cs
- HyperLinkStyle.cs
- ColumnMapProcessor.cs
- RegexCapture.cs
- RightsManagementErrorHandler.cs
- TextPattern.cs
- HorizontalAlignConverter.cs
- WhitespaceRuleLookup.cs
- LowerCaseStringConverter.cs
- ListBindingHelper.cs
- SystemWebSectionGroup.cs
- NavigationWindow.cs
- SystemIcons.cs
- FactoryGenerator.cs
- CreateUserWizard.cs
- DropDownButton.cs
- BooleanConverter.cs
- ColorMap.cs
- Dispatcher.cs
- GradientSpreadMethodValidation.cs
- MimeFormatExtensions.cs
- AnimationStorage.cs
- XmlObjectSerializerReadContext.cs
- MsdtcClusterUtils.cs
- ObjectHandle.cs
- SingleConverter.cs
- StreamGeometry.cs
- CompensationExtension.cs
- NotifyParentPropertyAttribute.cs
- GenericEnumerator.cs
- DebuggerService.cs
- MimeXmlImporter.cs
- EntityParameter.cs
- clipboard.cs
- EDesignUtil.cs
- Assert.cs
- WebPartEditorApplyVerb.cs
- DataGridViewButtonCell.cs
- Itemizer.cs
- DisplayInformation.cs
- AssemblyHash.cs
- HttpClientCertificate.cs