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
- PointF.cs
- InputMethod.cs
- ChildrenQuery.cs
- AtomServiceDocumentSerializer.cs
- UrlPath.cs
- InvokeWebServiceDesigner.cs
- SecurityManager.cs
- BlurEffect.cs
- EditorAttribute.cs
- MethodInfo.cs
- ExpressionEditor.cs
- LocationUpdates.cs
- PersistChildrenAttribute.cs
- GroupBoxRenderer.cs
- Parameter.cs
- InternalConfigHost.cs
- MoveSizeWinEventHandler.cs
- RepeatInfo.cs
- AnnotationService.cs
- Cell.cs
- CodeExpressionStatement.cs
- ServiceNameElement.cs
- AttributeUsageAttribute.cs
- Point3DIndependentAnimationStorage.cs
- MatrixConverter.cs
- PrintSystemException.cs
- DbConnectionStringBuilder.cs
- WebPartConnectionsCancelEventArgs.cs
- BooleanConverter.cs
- ExtentJoinTreeNode.cs
- KeyGestureValueSerializer.cs
- WebPartCloseVerb.cs
- AppDomainAttributes.cs
- State.cs
- Misc.cs
- UpdateRecord.cs
- AlternateViewCollection.cs
- TypeSchema.cs
- PerfService.cs
- TextEmbeddedObject.cs
- activationcontext.cs
- XPathDocumentIterator.cs
- HostingEnvironmentSection.cs
- ProviderSettingsCollection.cs
- OlePropertyStructs.cs
- prompt.cs
- TextAdaptor.cs
- StorageMappingItemLoader.cs
- DesignerVerb.cs
- ObjectListCommandsPage.cs
- Identity.cs
- TdsParserStaticMethods.cs
- WebBrowserSiteBase.cs
- Inflater.cs
- ClientReliableChannelBinder.cs
- LightweightCodeGenerator.cs
- EventArgs.cs
- SqlInfoMessageEvent.cs
- ContextInformation.cs
- SqlOuterApplyReducer.cs
- XmlStringTable.cs
- XsdDuration.cs
- MessageBox.cs
- DesigntimeLicenseContext.cs
- DefaultValueAttribute.cs
- HyperLinkDesigner.cs
- WebEventTraceProvider.cs
- FSWPathEditor.cs
- WsdlBuildProvider.cs
- DbConnectionPool.cs
- Timer.cs
- ReversePositionQuery.cs
- ExtendedProperty.cs
- PtsContext.cs
- ValidationService.cs
- SessionStateItemCollection.cs
- ToolBar.cs
- DataServiceEntityAttribute.cs
- ServiceHttpHandlerFactory.cs
- WsdlImporter.cs
- LogWriteRestartAreaState.cs
- LicenseManager.cs
- TemplateInstanceAttribute.cs
- TextMetrics.cs
- SHA256.cs
- ExpandoClass.cs
- TableRowGroup.cs
- InkCanvasSelectionAdorner.cs
- TextSelectionHighlightLayer.cs
- MsmqHostedTransportConfiguration.cs
- ProcessingInstructionAction.cs
- XsltCompileContext.cs
- CustomValidator.cs
- GeneratedContractType.cs
- RepeatBehaviorConverter.cs
- HttpRequest.cs
- ServerValidateEventArgs.cs
- FieldMetadata.cs
- SafeFileMapViewHandle.cs
- ValidatorCollection.cs