Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- BreakRecordTable.cs
- XPathNode.cs
- Deserializer.cs
- CompositeCollection.cs
- XmlQueryRuntime.cs
- WebMethodAttribute.cs
- Binding.cs
- CharAnimationBase.cs
- ButtonBase.cs
- BatchParser.cs
- Ppl.cs
- ContainerUIElement3D.cs
- VisualBasic.cs
- WindowsStatusBar.cs
- DrawingVisual.cs
- SystemResourceKey.cs
- XDeferredAxisSource.cs
- DataService.cs
- InvalidFilterCriteriaException.cs
- ChangePassword.cs
- DataControlFieldHeaderCell.cs
- XmlWrappingReader.cs
- TaskFileService.cs
- SecurityListenerSettingsLifetimeManager.cs
- SyncMethodInvoker.cs
- ToolboxDataAttribute.cs
- WebPartEditorCancelVerb.cs
- MobilePage.cs
- XdrBuilder.cs
- SharedPersonalizationStateInfo.cs
- XmlSigningNodeWriter.cs
- DataGridViewTopLeftHeaderCell.cs
- SoapMessage.cs
- BinaryWriter.cs
- EntityDataSourceConfigureObjectContext.cs
- Expression.cs
- StrokeCollection2.cs
- ColorConverter.cs
- RawStylusInput.cs
- TableSectionStyle.cs
- SQLBinaryStorage.cs
- SQLDecimal.cs
- WaitingCursor.cs
- PasswordTextContainer.cs
- ConstraintCollection.cs
- BitmapImage.cs
- DispatchWrapper.cs
- ConfigXmlWhitespace.cs
- AutomationPeer.cs
- _Events.cs
- UniqueConstraint.cs
- AnnotationService.cs
- Utils.cs
- OleDbTransaction.cs
- NumberSubstitution.cs
- SqlWebEventProvider.cs
- ChangePasswordDesigner.cs
- ExpressionBuilderCollection.cs
- TextRangeProviderWrapper.cs
- httpserverutility.cs
- OciEnlistContext.cs
- CancellableEnumerable.cs
- ArrangedElementCollection.cs
- EntityDataSourceSelectingEventArgs.cs
- BasicExpandProvider.cs
- InteropBitmapSource.cs
- HttpServerVarsCollection.cs
- BasicCommandTreeVisitor.cs
- CurrentChangingEventArgs.cs
- EntityObject.cs
- XmlDsigSep2000.cs
- Win32SafeHandles.cs
- Tag.cs
- BCryptNative.cs
- DateTimeConverter2.cs
- HyperLinkField.cs
- ControlValuePropertyAttribute.cs
- XamlSerializationHelper.cs
- CompiledAction.cs
- ApplicationProxyInternal.cs
- ButtonChrome.cs
- SchemaImporterExtensionElement.cs
- VariableModifiersHelper.cs
- DataGridRelationshipRow.cs
- PeerCollaboration.cs
- DecoderFallbackWithFailureFlag.cs
- Transform3DCollection.cs
- MediaContextNotificationWindow.cs
- PropertyIDSet.cs
- bidPrivateBase.cs
- RenderData.cs
- TraceProvider.cs
- RegexEditorDialog.cs
- formatstringdialog.cs
- ResourceDictionaryCollection.cs
- grammarelement.cs
- EmptyTextWriter.cs
- DependentList.cs
- Compiler.cs
- DragEvent.cs