Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / 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; } } }
Link Menu
![Network programming in C#, Network Programming in VB.NET, Network Programming in .NET](/images/book.jpg)
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- HttpWriter.cs
- JsonCollectionDataContract.cs
- RectAnimationBase.cs
- PkcsMisc.cs
- Drawing.cs
- Image.cs
- VisualStyleInformation.cs
- AsyncPostBackTrigger.cs
- GetPageCompletedEventArgs.cs
- DataTableTypeConverter.cs
- Italic.cs
- ExternalCalls.cs
- CompiledQueryCacheEntry.cs
- KeyInfo.cs
- XmlSchemaComplexContentExtension.cs
- ToolboxComponentsCreatedEventArgs.cs
- linebase.cs
- GridViewDeletedEventArgs.cs
- DictionarySectionHandler.cs
- CodeAccessSecurityEngine.cs
- EditorPart.cs
- DbConnectionPoolCounters.cs
- UserPreferenceChangedEventArgs.cs
- ActionNotSupportedException.cs
- DataGridItemCollection.cs
- CollectionChangedEventManager.cs
- RestClientProxyHandler.cs
- ConvertEvent.cs
- CompilationSection.cs
- Opcode.cs
- TileBrush.cs
- CodeChecksumPragma.cs
- PersonalizationProviderCollection.cs
- SafePEFileHandle.cs
- OrderingInfo.cs
- ContainerUIElement3D.cs
- PathFigure.cs
- TileBrush.cs
- DirectoryRedirect.cs
- AdvancedBindingPropertyDescriptor.cs
- IisTraceWebEventProvider.cs
- DetailsViewDeleteEventArgs.cs
- PlainXmlWriter.cs
- TreeNodeClickEventArgs.cs
- ValidatorCollection.cs
- DefaultHttpHandler.cs
- PasswordRecovery.cs
- TakeOrSkipQueryOperator.cs
- _TransmitFileOverlappedAsyncResult.cs
- MachineKeyConverter.cs
- Util.cs
- MulticastIPAddressInformationCollection.cs
- ValidatorCompatibilityHelper.cs
- DEREncoding.cs
- KnownTypes.cs
- EdmRelationshipNavigationPropertyAttribute.cs
- RightNameExpirationInfoPair.cs
- CompoundFileIOPermission.cs
- AlignmentXValidation.cs
- XmlTextReader.cs
- XPathDocumentIterator.cs
- LinearKeyFrames.cs
- Font.cs
- ControlEvent.cs
- Triangle.cs
- ExpressionConverter.cs
- DaylightTime.cs
- OletxEnlistment.cs
- ColorDialog.cs
- DataGridViewRow.cs
- ReadOnlyPropertyMetadata.cs
- InfoCardClaimCollection.cs
- GenericParameterDataContract.cs
- XmlSchemaAnyAttribute.cs
- PropertyDescriptor.cs
- DataGridColumnCollectionEditor.cs
- SafeArchiveContext.cs
- AesManaged.cs
- Inline.cs
- OrthographicCamera.cs
- CursorConverter.cs
- EventSinkHelperWriter.cs
- ReversePositionQuery.cs
- MimeMapping.cs
- RegexFCD.cs
- GcHandle.cs
- ExtendedPropertyDescriptor.cs
- FontUnit.cs
- EasingKeyFrames.cs
- X509SecurityTokenAuthenticator.cs
- CreateUserErrorEventArgs.cs
- VisualStateManager.cs
- MetadataUtil.cs
- relpropertyhelper.cs
- PropertyBuilder.cs
- ObjectHandle.cs
- StateMachine.cs
- EntityContainerRelationshipSet.cs
- System.Data_BID.cs
- CapabilitiesPattern.cs