Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / clr / src / BCL / System / Diagnostics / LogSwitch.cs / 1305376 / LogSwitch.cs
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
namespace System.Diagnostics {
using System;
using System.IO;
using System.Collections;
using System.Runtime.Versioning;
using System.Diagnostics.Contracts;
[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.
//
[System.Security.SecuritySafeCritical] // auto-generated
public LogSwitch(String name, String description, LogSwitch parent)
{
if (name != null && name.Length == 0)
throw new ArgumentOutOfRangeException("Name", Environment.GetResourceString("Argument_StringZeroLength"));
Contract.EndContractBlock();
if ((name != null) && (parent != null))
{
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"));
}
[System.Security.SecuritySafeCritical] // auto-generated
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; }
[System.Security.SecuritySafeCritical] // auto-generated
[ResourceExposure(ResourceScope.None)]
[ResourceConsumption(ResourceScope.Process, ResourceScope.Process)]
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;
using System.Runtime.Versioning;
using System.Diagnostics.Contracts;
[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.
//
[System.Security.SecuritySafeCritical] // auto-generated
public LogSwitch(String name, String description, LogSwitch parent)
{
if (name != null && name.Length == 0)
throw new ArgumentOutOfRangeException("Name", Environment.GetResourceString("Argument_StringZeroLength"));
Contract.EndContractBlock();
if ((name != null) && (parent != null))
{
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"));
}
[System.Security.SecuritySafeCritical] // auto-generated
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; }
[System.Security.SecuritySafeCritical] // auto-generated
[ResourceExposure(ResourceScope.None)]
[ResourceConsumption(ResourceScope.Process, ResourceScope.Process)]
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
- ApplicationInterop.cs
- PlaceHolder.cs
- serverconfig.cs
- GroupedContextMenuStrip.cs
- RenameRuleObjectDialog.cs
- LocatorPart.cs
- StrongNameUtility.cs
- TextStore.cs
- GroupLabel.cs
- TextureBrush.cs
- filewebrequest.cs
- Misc.cs
- MutexSecurity.cs
- Html32TextWriter.cs
- DecryptedHeader.cs
- XmlException.cs
- ArrayTypeMismatchException.cs
- SizeAnimationClockResource.cs
- ProcessModelInfo.cs
- VersionedStreamOwner.cs
- UserUseLicenseDictionaryLoader.cs
- ContentDisposition.cs
- RadioButtonFlatAdapter.cs
- SharedStream.cs
- BamlRecordHelper.cs
- Vars.cs
- SafeRightsManagementHandle.cs
- UmAlQuraCalendar.cs
- ChangesetResponse.cs
- BrowserDefinitionCollection.cs
- EtwTrackingParticipant.cs
- InputReportEventArgs.cs
- BindValidator.cs
- OrderToken.cs
- TriState.cs
- GcSettings.cs
- XmlSchemaException.cs
- RegularExpressionValidator.cs
- PlainXmlDeserializer.cs
- PackageDigitalSignatureManager.cs
- TreeView.cs
- RoleServiceManager.cs
- ArrayWithOffset.cs
- XmlSortKeyAccumulator.cs
- ReadOnlyHierarchicalDataSourceView.cs
- IndentTextWriter.cs
- MexNamedPipeBindingElement.cs
- Shape.cs
- MSG.cs
- HwndAppCommandInputProvider.cs
- Command.cs
- ValidationRuleCollection.cs
- UnsafeNativeMethods.cs
- Point3DAnimation.cs
- PackageDocument.cs
- IChannel.cs
- DaylightTime.cs
- AnnotationComponentChooser.cs
- RequestCacheValidator.cs
- DoWorkEventArgs.cs
- CngUIPolicy.cs
- TypeConstant.cs
- PersonalizationProviderCollection.cs
- BamlRecords.cs
- PageRanges.cs
- GroupDescription.cs
- DesignerVerb.cs
- ISAPIApplicationHost.cs
- versioninfo.cs
- CompiledQuery.cs
- sqlmetadatafactory.cs
- DrawingState.cs
- behaviorssection.cs
- InkCollectionBehavior.cs
- ListenerBinder.cs
- SizeFConverter.cs
- CapacityStreamGeometryContext.cs
- ThemeDirectoryCompiler.cs
- HttpServerVarsCollection.cs
- EntityDataSourceMemberPath.cs
- NCryptSafeHandles.cs
- GeometryGroup.cs
- HostDesigntimeLicenseContext.cs
- HttpModulesSection.cs
- RoleService.cs
- MessageSecurityProtocolFactory.cs
- ValidationEventArgs.cs
- ScalarType.cs
- Composition.cs
- RemoteX509Token.cs
- ISAPIApplicationHost.cs
- CallContext.cs
- StateDesigner.LayoutSelectionGlyph.cs
- AssemblySettingAttributes.cs
- SafeHandle.cs
- HtmlTableRowCollection.cs
- DataListCommandEventArgs.cs
- MethodCallExpression.cs
- ThumbAutomationPeer.cs
- MsdtcClusterUtils.cs