Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / CompMod / System / Diagnostics / TraceSwitch.cs / 1 / TraceSwitch.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* */ namespace System.Diagnostics { using System; using System.ComponentModel; using System.Security; using System.Security.Permissions; ////// [SwitchLevel(typeof(TraceLevel))] public class TraceSwitch : Switch { ///Provides a multi-level switch to enable or disable tracing /// and debug output for a compiled application or framework. ////// public TraceSwitch(string displayName, string description) : base(displayName, description) { } public TraceSwitch(string displayName, string description, string defaultSwitchValue) : base(displayName, description, defaultSwitchValue) { } ///Initializes a new instance of the ///class. /// public TraceLevel Level { get { return (TraceLevel)SwitchSetting; } [SecurityPermission(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.UnmanagedCode)] set { if (value < TraceLevel.Off || value > TraceLevel.Verbose) throw new ArgumentException(SR.GetString(SR.TraceSwitchInvalidLevel)); SwitchSetting = (int)value; } } ///Gets or sets the trace /// level that specifies what messages to output for tracing and debugging. ////// public bool TraceError { get { return (Level >= TraceLevel.Error); } } ///Gets a value /// indicating whether the ///is set to /// , , , or /// . /// public bool TraceWarning { get { return (Level >= TraceLevel.Warning); } } ///Gets a value /// indicating whether the ///is set to /// , , or . /// public bool TraceInfo { get { return (Level >= TraceLevel.Info); } } ///Gets a value /// indicating whether the ///is set to /// or . /// public bool TraceVerbose { get { return (Level == TraceLevel.Verbose); } } ///Gets a value /// indicating whether the ///is set to /// . /// protected override void OnSwitchSettingChanged() { int level = SwitchSetting; if (level < (int)TraceLevel.Off) { Trace.WriteLine(SR.GetString(SR.TraceSwitchLevelTooLow, DisplayName)); SwitchSetting = (int)TraceLevel.Off; } else if (level > (int)TraceLevel.Verbose) { Trace.WriteLine(SR.GetString(SR.TraceSwitchLevelTooHigh, DisplayName)); SwitchSetting = (int)TraceLevel.Verbose; } } protected override void OnValueChanged() { SwitchSetting = (int) Enum.Parse(typeof(TraceLevel), Value, true); } } }/// Update the level for this switch. /// ///
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ApplicationManager.cs
- FlowDocumentPage.cs
- ParsedAttributeCollection.cs
- EntitySqlQueryCacheKey.cs
- ApplicationProxyInternal.cs
- BoundsDrawingContextWalker.cs
- PolyBezierSegment.cs
- BaseCodeDomTreeGenerator.cs
- SecUtil.cs
- GlyphsSerializer.cs
- XmlILAnnotation.cs
- Utils.cs
- BaseInfoTable.cs
- SecurityPermission.cs
- uribuilder.cs
- SQLBytes.cs
- AdjustableArrowCap.cs
- IconConverter.cs
- XPathNode.cs
- PrintDocument.cs
- InternalDuplexChannelListener.cs
- MetadataItemEmitter.cs
- XmlSchemaAnyAttribute.cs
- DetailsViewCommandEventArgs.cs
- DependencyPropertyHelper.cs
- ImageSourceConverter.cs
- ConfigWriter.cs
- WindowsContainer.cs
- HostUtils.cs
- DbProviderFactory.cs
- HostingPreferredMapPath.cs
- AttributeAction.cs
- XPathNode.cs
- DataObject.cs
- WriteFileContext.cs
- RegionInfo.cs
- RegistryDataKey.cs
- BooleanAnimationUsingKeyFrames.cs
- FocusChangedEventArgs.cs
- PenContext.cs
- BinaryFormatterWriter.cs
- MTConfigUtil.cs
- Setter.cs
- EntityException.cs
- FixedSOMTable.cs
- BinaryReader.cs
- TemplateModeChangedEventArgs.cs
- XmlNavigatorStack.cs
- ExeConfigurationFileMap.cs
- xml.cs
- LocalizableAttribute.cs
- FixedFindEngine.cs
- Validator.cs
- Rotation3DAnimation.cs
- DataTableReaderListener.cs
- MSG.cs
- HttpWrapper.cs
- OracleString.cs
- ContainerControlDesigner.cs
- EncryptRequest.cs
- EntityModelSchemaGenerator.cs
- CommonBehaviorsSection.cs
- StateElementCollection.cs
- AtomContentProperty.cs
- FlowPosition.cs
- CodeCompileUnit.cs
- ColorMatrix.cs
- WebPartMenuStyle.cs
- DuplicateWaitObjectException.cs
- DataBindingExpressionBuilder.cs
- ProfilePropertyMetadata.cs
- TypedTableHandler.cs
- CommonDialog.cs
- RoleGroup.cs
- XLinq.cs
- UnsafeNativeMethods.cs
- XmlConvert.cs
- XamlSerializationHelper.cs
- JournalEntry.cs
- MeasureItemEvent.cs
- SerializationFieldInfo.cs
- DesignerCategoryAttribute.cs
- RecognitionEventArgs.cs
- UInt64Storage.cs
- UpdatePanelTriggerCollection.cs
- ResourceManager.cs
- ReadOnlyCollectionBase.cs
- Mouse.cs
- ExpressionLexer.cs
- SchemaImporter.cs
- AsmxEndpointPickerExtension.cs
- FontSource.cs
- TypeUnloadedException.cs
- WhitespaceSignificantCollectionAttribute.cs
- PersonalizationState.cs
- ValueConversionAttribute.cs
- EventLogPermission.cs
- UIPermission.cs
- KeyGesture.cs
- MultipartContentParser.cs