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
- Compiler.cs
- FixedSOMGroup.cs
- Variable.cs
- DataServiceRequestException.cs
- Membership.cs
- MobileErrorInfo.cs
- SetterTriggerConditionValueConverter.cs
- ConnectionStringEditor.cs
- MaskedTextProvider.cs
- CompletedAsyncResult.cs
- StructuralType.cs
- ThicknessAnimationBase.cs
- RpcAsyncResult.cs
- CurrencyManager.cs
- Model3DGroup.cs
- ColorTransformHelper.cs
- _UriSyntax.cs
- StringAnimationUsingKeyFrames.cs
- JobPageOrder.cs
- QueryContinueDragEvent.cs
- COM2ColorConverter.cs
- RIPEMD160.cs
- SupportsEventValidationAttribute.cs
- HeaderUtility.cs
- DrawTreeNodeEventArgs.cs
- WindowsTreeView.cs
- CharacterBuffer.cs
- ISessionStateStore.cs
- EnvelopedSignatureTransform.cs
- OutputCacheModule.cs
- ForceCopyBuildProvider.cs
- InputScopeAttribute.cs
- GroupJoinQueryOperator.cs
- SoapReflectionImporter.cs
- WebPartAddingEventArgs.cs
- TextTreeUndo.cs
- WSHttpBinding.cs
- CommandField.cs
- DetailsViewModeEventArgs.cs
- _LocalDataStore.cs
- CacheChildrenQuery.cs
- AnimationException.cs
- FixUp.cs
- StorageRoot.cs
- DataGridItem.cs
- DataColumn.cs
- ScriptDescriptor.cs
- SqlAggregateChecker.cs
- UrlPropertyAttribute.cs
- ThreadStateException.cs
- KnownColorTable.cs
- BindingExpressionUncommonField.cs
- AsynchronousChannel.cs
- WebPartMenu.cs
- StringInfo.cs
- ComAdminInterfaces.cs
- BroadcastEventHelper.cs
- DbConnectionPoolOptions.cs
- Control.cs
- ControlDesigner.cs
- ScrollBar.cs
- FileAuthorizationModule.cs
- BaseInfoTable.cs
- DbgUtil.cs
- SQLInt64.cs
- ListBoxItemAutomationPeer.cs
- EventLogPermissionEntryCollection.cs
- base64Transforms.cs
- XmlChoiceIdentifierAttribute.cs
- WebException.cs
- srgsitem.cs
- XamlTypeMapper.cs
- URLIdentityPermission.cs
- EnumValAlphaComparer.cs
- BoundField.cs
- BinaryCommonClasses.cs
- ipaddressinformationcollection.cs
- MessageQueueInstaller.cs
- TextComposition.cs
- PackWebRequestFactory.cs
- BatchParser.cs
- ObjectComplexPropertyMapping.cs
- MarkupCompilePass1.cs
- WindowProviderWrapper.cs
- ProgressBarAutomationPeer.cs
- FormatException.cs
- DesignerTextBoxAdapter.cs
- IdSpace.cs
- SimpleTypesSurrogate.cs
- DesignerDataRelationship.cs
- Size.cs
- PagedDataSource.cs
- FormatConvertedBitmap.cs
- FixedDSBuilder.cs
- DataObject.cs
- EventLogEntry.cs
- EntitySetBaseCollection.cs
- SID.cs
- IDQuery.cs
- XPathPatternParser.cs