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
- ResourcesBuildProvider.cs
- PropVariant.cs
- Propagator.JoinPropagator.cs
- FigureParagraph.cs
- ReadOnlyCollection.cs
- SpellerHighlightLayer.cs
- CodeTypeReferenceExpression.cs
- KeyConverter.cs
- QilCloneVisitor.cs
- StateInitialization.cs
- OrderPreservingPipeliningSpoolingTask.cs
- EFAssociationProvider.cs
- ComponentDesigner.cs
- TheQuery.cs
- XmlEnumAttribute.cs
- DataGridPagerStyle.cs
- ChannelManager.cs
- KnownTypesHelper.cs
- Win32MouseDevice.cs
- SequenceFullException.cs
- ImageBrush.cs
- Activator.cs
- FileIOPermission.cs
- ListBox.cs
- IsolatedStorageFileStream.cs
- SecurityTokenContainer.cs
- ZipFileInfoCollection.cs
- _ScatterGatherBuffers.cs
- DependentList.cs
- SystemIcmpV4Statistics.cs
- FormClosedEvent.cs
- _HeaderInfo.cs
- ServiceOperation.cs
- RoutedPropertyChangedEventArgs.cs
- ColorConverter.cs
- ProviderConnectionPoint.cs
- XmlObjectSerializerReadContextComplex.cs
- CopyNamespacesAction.cs
- ManagedCodeMarkers.cs
- ListBoxAutomationPeer.cs
- ToolBar.cs
- CriticalHandle.cs
- SerialPort.cs
- CompositionAdorner.cs
- DockPattern.cs
- DispatcherTimer.cs
- Stopwatch.cs
- BaseTransportHeaders.cs
- OciLobLocator.cs
- HttpWebRequest.cs
- WriteableOnDemandStream.cs
- ReadOnlyDataSource.cs
- WindowsFormsSynchronizationContext.cs
- PropertyBuilder.cs
- OleDbReferenceCollection.cs
- CodeCatchClause.cs
- RequestCacheManager.cs
- SqlInternalConnectionTds.cs
- DescendentsWalkerBase.cs
- Subtree.cs
- SynchronizedKeyedCollection.cs
- BitmapMetadata.cs
- SimpleExpression.cs
- CaseInsensitiveComparer.cs
- QueryableDataSourceView.cs
- Parameter.cs
- TypeResolvingOptions.cs
- NameValuePair.cs
- DocumentsTrace.cs
- QilFactory.cs
- OleDbParameterCollection.cs
- ContentPlaceHolder.cs
- EnumType.cs
- BatchWriter.cs
- TransactionContext.cs
- ApplicationProxyInternal.cs
- IODescriptionAttribute.cs
- PeerCustomResolverElement.cs
- MessageFormatterConverter.cs
- ColorEditor.cs
- RotateTransform3D.cs
- PolicyException.cs
- BasicViewGenerator.cs
- TypedTableBaseExtensions.cs
- HttpWebResponse.cs
- ToolStripStatusLabel.cs
- EditCommandColumn.cs
- TdsParameterSetter.cs
- InvokeHandlers.cs
- DataSourceSelectArguments.cs
- HtmlSelect.cs
- DataTableReader.cs
- CustomTypeDescriptor.cs
- FileDialogCustomPlacesCollection.cs
- StyleCollection.cs
- AstTree.cs
- PropertyGridCommands.cs
- WebResourceAttribute.cs
- JsonXmlDataContract.cs
- ConfigXmlWhitespace.cs