Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ ///// Update the level for this switch. /// ///// 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); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007./// Update the level for this switch. /// ///
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- PagesChangedEventArgs.cs
- SafeCoTaskMem.cs
- EFColumnProvider.cs
- ExecutionEngineException.cs
- ProxyHelper.cs
- InertiaRotationBehavior.cs
- ToolStripCodeDomSerializer.cs
- FactoryMaker.cs
- TextReturnReader.cs
- RegexFCD.cs
- RequiredFieldValidator.cs
- BitArray.cs
- SqlTransaction.cs
- BaseDataListDesigner.cs
- SecurityTokenResolver.cs
- NumberFunctions.cs
- RequestNavigateEventArgs.cs
- StringPropertyBuilder.cs
- Image.cs
- StringDictionaryCodeDomSerializer.cs
- DataGridViewMethods.cs
- validation.cs
- ClipboardProcessor.cs
- ArcSegment.cs
- FragmentQueryKB.cs
- XmlAttributeOverrides.cs
- DodSequenceMerge.cs
- StickyNoteHelper.cs
- ChangesetResponse.cs
- EnumerableCollectionView.cs
- InvariantComparer.cs
- WindowsToolbarAsMenu.cs
- AtomServiceDocumentSerializer.cs
- entitydatasourceentitysetnameconverter.cs
- MenuItemAutomationPeer.cs
- DocumentViewerBase.cs
- CompatibleIComparer.cs
- TrackingAnnotationCollection.cs
- ConnectionStringsExpressionBuilder.cs
- ZipIOCentralDirectoryDigitalSignature.cs
- SqlConnectionHelper.cs
- DockPanel.cs
- ListenerServiceInstallComponent.cs
- InternalConfigEventArgs.cs
- KeyNotFoundException.cs
- ResponseStream.cs
- XmlCharType.cs
- UInt32Storage.cs
- TextEndOfParagraph.cs
- CatalogZoneBase.cs
- DesignerUtils.cs
- RegistryExceptionHelper.cs
- CaseInsensitiveHashCodeProvider.cs
- Size3D.cs
- UntrustedRecipientException.cs
- Image.cs
- WrappedOptions.cs
- InstanceDataCollection.cs
- WriteableBitmap.cs
- RequestQueryParser.cs
- RelatedPropertyManager.cs
- SignedPkcs7.cs
- TypeDescriptionProvider.cs
- ParamArrayAttribute.cs
- OpacityConverter.cs
- SmiEventSink_DeferedProcessing.cs
- ConditionalBranch.cs
- cache.cs
- messageonlyhwndwrapper.cs
- Utils.cs
- CodeAccessSecurityEngine.cs
- HMACRIPEMD160.cs
- WindowInteropHelper.cs
- ThicknessAnimationUsingKeyFrames.cs
- ActivationArguments.cs
- TextTreeText.cs
- PersonalizationStateInfoCollection.cs
- Vector3DKeyFrameCollection.cs
- EditorZoneAutoFormat.cs
- AnimationTimeline.cs
- ItemType.cs
- StrokeCollectionConverter.cs
- FirstMatchCodeGroup.cs
- PlainXmlDeserializer.cs
- TripleDESCryptoServiceProvider.cs
- AssemblyName.cs
- ParseChildrenAsPropertiesAttribute.cs
- TagPrefixAttribute.cs
- ObjectItemConventionAssemblyLoader.cs
- ProcessModelInfo.cs
- BoundsDrawingContextWalker.cs
- EmbeddedMailObjectsCollection.cs
- ParserOptions.cs
- TailPinnedEventArgs.cs
- TextPattern.cs
- ProcessHost.cs
- File.cs
- ObjectQueryProvider.cs
- ProxyWebPart.cs
- AppDomainProtocolHandler.cs