Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / CompMod / System / Diagnostics / TraceSwitch.cs / 1305376 / 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
- BoundField.cs
- PersistenceProvider.cs
- PermissionSet.cs
- SecUtil.cs
- ExtentCqlBlock.cs
- TraceUtils.cs
- WindowsListViewSubItem.cs
- ToolStripSystemRenderer.cs
- ExceptionNotification.cs
- OdbcError.cs
- ConnectionPointConverter.cs
- UserControlParser.cs
- TableLayoutSettings.cs
- ConvertTextFrag.cs
- COM2ColorConverter.cs
- BinaryObjectInfo.cs
- SymbolDocumentGenerator.cs
- AsymmetricSignatureDeformatter.cs
- VectorCollectionConverter.cs
- TextComposition.cs
- SafePointer.cs
- ObjectHandle.cs
- WebPartConnectionsCancelEventArgs.cs
- WmpBitmapEncoder.cs
- CodeSubDirectory.cs
- FullTextLine.cs
- KeyFrames.cs
- XmlSerializerFactory.cs
- XslTransform.cs
- GatewayIPAddressInformationCollection.cs
- SqlProviderServices.cs
- SynchronizedInputPattern.cs
- SecurityNegotiationException.cs
- VersionPair.cs
- MULTI_QI.cs
- MouseButtonEventArgs.cs
- DLinqAssociationProvider.cs
- XsltContext.cs
- DrawListViewColumnHeaderEventArgs.cs
- AttachedAnnotation.cs
- ReadOnlyPermissionSet.cs
- AppSettingsExpressionEditor.cs
- HttpRequestContext.cs
- _BufferOffsetSize.cs
- HashAlgorithm.cs
- DataGridViewTopLeftHeaderCell.cs
- LabelDesigner.cs
- ComboBox.cs
- PageFunction.cs
- BindUriHelper.cs
- VirtualDirectoryMapping.cs
- ResourceExpression.cs
- ItemCheckedEvent.cs
- GPRECT.cs
- XmlQualifiedNameTest.cs
- querybuilder.cs
- DoubleUtil.cs
- SimpleTextLine.cs
- AuthenticationException.cs
- XmlMapping.cs
- OpenTypeCommon.cs
- DependencyPropertyValueSerializer.cs
- EmbeddedMailObjectsCollection.cs
- CodeConstructor.cs
- TrailingSpaceComparer.cs
- PeerConnector.cs
- PersonalizationState.cs
- ErrorStyle.cs
- Vector3DAnimationBase.cs
- SudsWriter.cs
- DateTimeConverter.cs
- SqlProviderServices.cs
- IdentifierService.cs
- FormViewModeEventArgs.cs
- XmlKeywords.cs
- EntityReference.cs
- RadioButton.cs
- InteropEnvironment.cs
- FormattedText.cs
- InputScope.cs
- SqlProfileProvider.cs
- PassportAuthenticationEventArgs.cs
- GeneralTransform3DGroup.cs
- RepeatButton.cs
- DataGridViewRowHeightInfoNeededEventArgs.cs
- WebPartTransformerAttribute.cs
- FileFormatException.cs
- ProviderConnectionPointCollection.cs
- StoreAnnotationsMap.cs
- DesignerAdapterUtil.cs
- ViewGenResults.cs
- _SecureChannel.cs
- QueryContinueDragEvent.cs
- FilterableAttribute.cs
- SchemaMapping.cs
- StrokeCollection2.cs
- ComboBoxAutomationPeer.cs
- TypeLoadException.cs
- WindowsGraphics2.cs
- RuleSetDialog.cs