Code:
/ DotNET / DotNET / 8.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
- DebuggerAttributes.cs
- RuleInfoComparer.cs
- MenuCommand.cs
- ApplicationProxyInternal.cs
- DependencyPropertyKey.cs
- EndGetFileNameFromUserRequest.cs
- HMACSHA256.cs
- StrokeNodeData.cs
- WebUtil.cs
- ResourceWriter.cs
- DetailsViewInsertedEventArgs.cs
- CodeGotoStatement.cs
- ToolboxDataAttribute.cs
- PageCodeDomTreeGenerator.cs
- RootProfilePropertySettingsCollection.cs
- FixedDocumentSequencePaginator.cs
- ErrorLog.cs
- _DisconnectOverlappedAsyncResult.cs
- DropSource.cs
- MouseGesture.cs
- PriorityChain.cs
- LinqDataSourceInsertEventArgs.cs
- CompressEmulationStream.cs
- BitmapEncoder.cs
- ObjectStateEntry.cs
- GroupDescription.cs
- CancellationHandler.cs
- WindowsMenu.cs
- DefaultPrintController.cs
- Label.cs
- Process.cs
- SafeRegistryHandle.cs
- DockPattern.cs
- HtmlTableRow.cs
- XmlSerializerVersionAttribute.cs
- FrameworkContentElement.cs
- FormsAuthenticationConfiguration.cs
- WorkItem.cs
- MetadataUtilsSmi.cs
- SafeCoTaskMem.cs
- ReflectionTypeLoadException.cs
- TypeLibConverter.cs
- KnownTypesProvider.cs
- PolicyManager.cs
- FilterEventArgs.cs
- COM2ICategorizePropertiesHandler.cs
- ProfileModule.cs
- Rectangle.cs
- SimplePropertyEntry.cs
- Vector3D.cs
- Transactions.cs
- HighContrastHelper.cs
- CompoundFileStreamReference.cs
- ColorTransformHelper.cs
- TdsParserHelperClasses.cs
- GetPageNumberCompletedEventArgs.cs
- CodeLabeledStatement.cs
- webeventbuffer.cs
- ReadOnlyDataSource.cs
- SqlTypeConverter.cs
- LookupNode.cs
- OverlappedAsyncResult.cs
- ConfigXmlSignificantWhitespace.cs
- StorageFunctionMapping.cs
- CompModSwitches.cs
- util.cs
- FixedSOMImage.cs
- ContentType.cs
- SeverityFilter.cs
- OleDbParameterCollection.cs
- RoleGroup.cs
- RegexParser.cs
- LightweightCodeGenerator.cs
- ViewDesigner.cs
- SqlBulkCopyColumnMappingCollection.cs
- MsmqIntegrationAppDomainProtocolHandler.cs
- Thickness.cs
- ListViewContainer.cs
- SqlCacheDependencyDatabase.cs
- DynamicActivityTypeDescriptor.cs
- ResourceWriter.cs
- DiscreteKeyFrames.cs
- XPathNodePointer.cs
- Geometry.cs
- InternalException.cs
- Fault.cs
- DependencyPropertyAttribute.cs
- CompensationParticipant.cs
- RtfToken.cs
- RelationshipEndCollection.cs
- DataSourceSelectArguments.cs
- RepeaterCommandEventArgs.cs
- X509RawDataKeyIdentifierClause.cs
- DescendantBaseQuery.cs
- XPathSingletonIterator.cs
- ProxyHwnd.cs
- NotifyParentPropertyAttribute.cs
- UrlAuthorizationModule.cs
- EndOfStreamException.cs
- UrlPath.cs