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
- Security.cs
- PropertyItem.cs
- ToolStripItemImageRenderEventArgs.cs
- Track.cs
- ExecutionContext.cs
- StylusPoint.cs
- HtmlInputButton.cs
- ClientBuildManagerCallback.cs
- InputElement.cs
- IncomingWebRequestContext.cs
- BrowserTree.cs
- HWStack.cs
- MetadataUtilsSmi.cs
- MdiWindowListItemConverter.cs
- SetterTriggerConditionValueConverter.cs
- ButtonBase.cs
- AssemblyLoader.cs
- httpstaticobjectscollection.cs
- MimeTypeAttribute.cs
- processwaithandle.cs
- PartialArray.cs
- HandleValueEditor.cs
- BaseTemplateBuildProvider.cs
- MessageDesigner.cs
- UserControl.cs
- OptimisticConcurrencyException.cs
- TextWriterEngine.cs
- NativeBuffer.cs
- TypeViewSchema.cs
- OraclePermissionAttribute.cs
- AppSettingsExpressionBuilder.cs
- DllNotFoundException.cs
- ControlBuilder.cs
- FormViewUpdateEventArgs.cs
- ErrorFormatterPage.cs
- Compiler.cs
- SignalGate.cs
- ApplicationDirectoryMembershipCondition.cs
- BooleanSwitch.cs
- AutomationElement.cs
- SQLUtility.cs
- ArraySubsetEnumerator.cs
- SpecialFolderEnumConverter.cs
- UpdateTracker.cs
- ShaderRenderModeValidation.cs
- NegotiationTokenAuthenticatorStateCache.cs
- ActivationWorker.cs
- WebServiceClientProxyGenerator.cs
- ClientSettingsSection.cs
- Base64Decoder.cs
- GenerateTemporaryTargetAssembly.cs
- WebPartTransformer.cs
- TableItemProviderWrapper.cs
- RestClientProxyHandler.cs
- MobileResource.cs
- wmiprovider.cs
- QueueProcessor.cs
- PenContext.cs
- ObjectSet.cs
- ResXFileRef.cs
- XamlFilter.cs
- SvcFileManager.cs
- XmlNamedNodeMap.cs
- StoreItemCollection.Loader.cs
- CurrencyWrapper.cs
- PersonalizationDictionary.cs
- MimeMultiPart.cs
- PageParserFilter.cs
- Bold.cs
- SecurityDescriptor.cs
- DbBuffer.cs
- TriggerActionCollection.cs
- GridItemPatternIdentifiers.cs
- GC.cs
- DesignerVerb.cs
- DesignOnlyAttribute.cs
- TextEditorTables.cs
- ThemeDirectoryCompiler.cs
- UTF8Encoding.cs
- WeakReferenceKey.cs
- WsatExtendedInformation.cs
- BaseTemplateCodeDomTreeGenerator.cs
- EventProxy.cs
- ConsoleCancelEventArgs.cs
- WebBrowserNavigatingEventHandler.cs
- ToolStrip.cs
- ServiceObjectContainer.cs
- UInt16.cs
- Error.cs
- GatewayIPAddressInformationCollection.cs
- GorillaCodec.cs
- NameSpaceExtractor.cs
- IdentityReference.cs
- ByteStack.cs
- contentDescriptor.cs
- TemplateNameScope.cs
- XamlBuildTaskServices.cs
- MorphHelper.cs
- XmlSerializableServices.cs
- DataGridViewCellParsingEventArgs.cs