Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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
- GridViewHeaderRowPresenterAutomationPeer.cs
- DecoderNLS.cs
- HighlightVisual.cs
- ControlParameter.cs
- SHA512.cs
- DesignerDataView.cs
- CqlQuery.cs
- ContentValidator.cs
- Stylesheet.cs
- XmlReader.cs
- ObjRef.cs
- CommandEventArgs.cs
- ObjectManager.cs
- RegexMatchCollection.cs
- GroupStyle.cs
- WorkflowQueuingService.cs
- WebPartTransformer.cs
- MethodBody.cs
- EdmComplexTypeAttribute.cs
- SettingsBindableAttribute.cs
- Rule.cs
- LambdaCompiler.Address.cs
- HtmlElementEventArgs.cs
- Convert.cs
- PropertyItemInternal.cs
- Polygon.cs
- DocumentViewerConstants.cs
- HtmlTableRow.cs
- UriParserTemplates.cs
- SvcMapFile.cs
- AlphabeticalEnumConverter.cs
- cookieexception.cs
- HeaderCollection.cs
- Tool.cs
- ControlBuilder.cs
- SignatureDescription.cs
- WebPartConnectionsCancelEventArgs.cs
- ValidatorCollection.cs
- ToolboxBitmapAttribute.cs
- VBCodeProvider.cs
- TableSectionStyle.cs
- CompilerGlobalScopeAttribute.cs
- XPathArrayIterator.cs
- Triplet.cs
- SchemaCollectionPreprocessor.cs
- HostedImpersonationContext.cs
- EntryIndex.cs
- FixedSOMLineCollection.cs
- PasswordTextNavigator.cs
- entityreference_tresulttype.cs
- DbInsertCommandTree.cs
- SqlCacheDependencyDatabase.cs
- SystemIcmpV4Statistics.cs
- XmlNamedNodeMap.cs
- ZipIOFileItemStream.cs
- ImageUrlEditor.cs
- ScriptResourceDefinition.cs
- XmlTextEncoder.cs
- ParallelDesigner.cs
- IDQuery.cs
- StateInitializationDesigner.cs
- XmlAttributeCollection.cs
- MessageAction.cs
- PropertyStore.cs
- HostedTransportConfigurationManager.cs
- BaseProcessor.cs
- MachineKeySection.cs
- KnownBoxes.cs
- MissingManifestResourceException.cs
- COM2EnumConverter.cs
- OracleConnectionString.cs
- Rect3DConverter.cs
- HtmlAnchor.cs
- SqlProfileProvider.cs
- DataBoundControlHelper.cs
- CodeExporter.cs
- WorkflowNamespace.cs
- EventLog.cs
- CellIdBoolean.cs
- __ConsoleStream.cs
- HashMembershipCondition.cs
- followingquery.cs
- MeasurementDCInfo.cs
- DbMetaDataFactory.cs
- XLinq.cs
- VarInfo.cs
- SurrogateEncoder.cs
- Zone.cs
- OdbcParameterCollection.cs
- Line.cs
- DataGridViewCellStateChangedEventArgs.cs
- PointCollection.cs
- DiagnosticsConfiguration.cs
- DataAdapter.cs
- X509ChainElement.cs
- PtsPage.cs
- EpmSourcePathSegment.cs
- ThaiBuddhistCalendar.cs
- ProxyWebPartConnectionCollection.cs
- SectionXmlInfo.cs