Code:
/ FX-1434 / FX-1434 / 1.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
- QueryCorrelationInitializer.cs
- Subset.cs
- TimeoutException.cs
- WebDescriptionAttribute.cs
- EncodingStreamWrapper.cs
- BrowserCapabilitiesFactory.cs
- PropertyDescriptorCollection.cs
- WindowExtensionMethods.cs
- FirstQueryOperator.cs
- SoapAttributeAttribute.cs
- InvocationExpression.cs
- MarginsConverter.cs
- BinaryEditor.cs
- EntityRecordInfo.cs
- TextElementEnumerator.cs
- StringSorter.cs
- TextPenaltyModule.cs
- ColorKeyFrameCollection.cs
- LoginView.cs
- EntitySqlException.cs
- ValidationManager.cs
- cookiecontainer.cs
- TreeNodeCollectionEditor.cs
- DesignerHierarchicalDataSourceView.cs
- BlurBitmapEffect.cs
- SiteIdentityPermission.cs
- StateChangeEvent.cs
- ExpressionList.cs
- ProfileModule.cs
- ReadOnlyHierarchicalDataSource.cs
- StateMachineWorkflowInstance.cs
- MsmqTransportReceiveParameters.cs
- StringTraceRecord.cs
- DebugView.cs
- FindSimilarActivitiesVerb.cs
- ServiceDebugBehavior.cs
- ClientRolePrincipal.cs
- CompositeFontInfo.cs
- IsolatedStoragePermission.cs
- PropertyItemInternal.cs
- ResourceIDHelper.cs
- OverrideMode.cs
- OuterGlowBitmapEffect.cs
- CollectionEditorDialog.cs
- AddValidationError.cs
- HttpListenerRequest.cs
- TextBoxBase.cs
- HttpApplication.cs
- SQLBinary.cs
- PenThreadWorker.cs
- PageBuildProvider.cs
- WindowsEditBox.cs
- CacheChildrenQuery.cs
- RegexTree.cs
- TextFormatter.cs
- PageOrientation.cs
- HttpWebResponse.cs
- IisTraceWebEventProvider.cs
- IndexedString.cs
- XPathSelfQuery.cs
- __Error.cs
- ScriptRef.cs
- _NetRes.cs
- NameSpaceExtractor.cs
- SizeIndependentAnimationStorage.cs
- EncoderExceptionFallback.cs
- SliderAutomationPeer.cs
- RewritingPass.cs
- TypeInitializationException.cs
- Style.cs
- LinkedDataMemberFieldEditor.cs
- BehaviorEditorPart.cs
- Misc.cs
- MenuAdapter.cs
- GroupBox.cs
- InternalSafeNativeMethods.cs
- DateTimeFormatInfo.cs
- GridView.cs
- MarginsConverter.cs
- XmlByteStreamWriter.cs
- EastAsianLunisolarCalendar.cs
- Crypto.cs
- DataContractSet.cs
- ByeOperationAsyncResult.cs
- Error.cs
- AssemblySettingAttributes.cs
- PagerSettings.cs
- Stackframe.cs
- BufferModesCollection.cs
- UInt32Storage.cs
- HtmlWindow.cs
- FragmentQueryKB.cs
- AppSettingsSection.cs
- GridViewEditEventArgs.cs
- TextTreeObjectNode.cs
- EngineSite.cs
- ByteViewer.cs
- OdbcFactory.cs
- EntityModelSchemaGenerator.cs
- BrowserDefinitionCollection.cs