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
- TextRangeProviderWrapper.cs
- AspProxy.cs
- DeadCharTextComposition.cs
- ConvertersCollection.cs
- returneventsaver.cs
- URLString.cs
- glyphs.cs
- FrugalList.cs
- IsolatedStorageFilePermission.cs
- XslCompiledTransform.cs
- RecognizedAudio.cs
- QuaternionConverter.cs
- SecurityResources.cs
- HtmlElementErrorEventArgs.cs
- Formatter.cs
- DecimalConstantAttribute.cs
- BamlRecordWriter.cs
- ResourceExpressionBuilder.cs
- ObjectNavigationPropertyMapping.cs
- GuidelineCollection.cs
- SafePEFileHandle.cs
- _ShellExpression.cs
- NativeMethods.cs
- ProxyGenerationError.cs
- SocketElement.cs
- StoragePropertyMapping.cs
- HandlerFactoryCache.cs
- AttributeUsageAttribute.cs
- BrushConverter.cs
- StringExpressionSet.cs
- StrokeCollection2.cs
- TabRenderer.cs
- GraphicsContainer.cs
- RulePatternOps.cs
- DuplicateWaitObjectException.cs
- XmlSchemaAppInfo.cs
- LogicalTreeHelper.cs
- WindowsTreeView.cs
- LinkTarget.cs
- XmlDocumentFragment.cs
- EventPrivateKey.cs
- WebReferenceCollection.cs
- AudioFormatConverter.cs
- ParameterModifier.cs
- XmlTextWriter.cs
- DeadCharTextComposition.cs
- EventProviderClassic.cs
- SynthesizerStateChangedEventArgs.cs
- NumericExpr.cs
- ContextStaticAttribute.cs
- Attributes.cs
- DiagnosticStrings.cs
- TrustLevel.cs
- XmlWriterDelegator.cs
- PackageDigitalSignature.cs
- SafeRegistryHandle.cs
- EmptyControlCollection.cs
- MemoryPressure.cs
- GradientStopCollection.cs
- BufferedGraphicsManager.cs
- SafeUserTokenHandle.cs
- OutputCacheProfile.cs
- OuterGlowBitmapEffect.cs
- DocumentPageViewAutomationPeer.cs
- NotificationContext.cs
- nulltextcontainer.cs
- StyleConverter.cs
- DataGridViewRowsRemovedEventArgs.cs
- WorkflowInstanceAbortedRecord.cs
- _Rfc2616CacheValidators.cs
- DataGridColumnCollection.cs
- SiteOfOriginContainer.cs
- CompoundFileStorageReference.cs
- ManifestBasedResourceGroveler.cs
- TraceListeners.cs
- NamespaceEmitter.cs
- ReadOnlyHierarchicalDataSource.cs
- ExclusiveTcpListener.cs
- SqlParameter.cs
- TextBlockAutomationPeer.cs
- EnvelopedSignatureTransform.cs
- SymbolType.cs
- SQLBytesStorage.cs
- BaseCodePageEncoding.cs
- DataSourceGeneratorException.cs
- IndexingContentUnit.cs
- LayoutTableCell.cs
- ExtensionCollection.cs
- CombinedGeometry.cs
- EnumConverter.cs
- MouseWheelEventArgs.cs
- LineBreakRecord.cs
- ChangeConflicts.cs
- InputScope.cs
- XmlDocument.cs
- BamlStream.cs
- HttpResponseInternalWrapper.cs
- BCryptNative.cs
- ExtensionQuery.cs
- OutputCacheSection.cs