Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / CompMod / System / Diagnostics / TraceSwitch.cs / 1305376 / 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); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ ///// Update the level for this switch. /// ///// 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); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007./// Update the level for this switch. /// ///
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- AuthenticationModulesSection.cs
- StyleXamlTreeBuilder.cs
- XmlName.cs
- SchemaCollectionPreprocessor.cs
- ComplusTypeValidator.cs
- altserialization.cs
- WorkflowMarkupSerializationProvider.cs
- ReadOnlyAttribute.cs
- MetadataHelper.cs
- EventTrigger.cs
- PropertyValueChangedEvent.cs
- CommandID.cs
- SoapClientMessage.cs
- SettingsSavedEventArgs.cs
- SystemSounds.cs
- PeerNameRegistration.cs
- ThicknessAnimation.cs
- LineSegment.cs
- URLBuilder.cs
- RangeEnumerable.cs
- BindableTemplateBuilder.cs
- MetadataItemSerializer.cs
- Utility.cs
- StreamUpdate.cs
- AuthorizationRuleCollection.cs
- SafeReversePInvokeHandle.cs
- WebScriptClientGenerator.cs
- VirtualPathUtility.cs
- CodeThrowExceptionStatement.cs
- GenericAuthenticationEventArgs.cs
- IncrementalReadDecoders.cs
- HostingEnvironmentException.cs
- WebPartCancelEventArgs.cs
- BroadcastEventHelper.cs
- ToolStripSeparator.cs
- IgnorePropertiesAttribute.cs
- StrokeCollection2.cs
- WinInet.cs
- MemberMaps.cs
- DropSource.cs
- DependencyPropertyAttribute.cs
- PointCollection.cs
- BitmapVisualManager.cs
- WmlTextViewAdapter.cs
- ButtonChrome.cs
- VectorConverter.cs
- DBCSCodePageEncoding.cs
- _NtlmClient.cs
- RangeBase.cs
- DocumentXPathNavigator.cs
- LayoutManager.cs
- TrackingStringDictionary.cs
- SafeHandles.cs
- SqlDataSourceView.cs
- HttpCacheParams.cs
- InputLanguageSource.cs
- DSACryptoServiceProvider.cs
- _KerberosClient.cs
- HyperLinkColumn.cs
- Clipboard.cs
- TableRowCollection.cs
- ScriptControlManager.cs
- XmlNode.cs
- StickyNoteHelper.cs
- SizeValueSerializer.cs
- SecurityDescriptor.cs
- ContextMenu.cs
- LoadGrammarCompletedEventArgs.cs
- DataSourceXmlSerializer.cs
- Filter.cs
- BitmapEffectInput.cs
- ServiceDescriptionSerializer.cs
- PageCodeDomTreeGenerator.cs
- CustomError.cs
- WebEventTraceProvider.cs
- InternalControlCollection.cs
- AvTraceFormat.cs
- GraphicsState.cs
- SeekableMessageNavigator.cs
- StackOverflowException.cs
- OperationCanceledException.cs
- GlyphCache.cs
- ToolStripCodeDomSerializer.cs
- UnicastIPAddressInformationCollection.cs
- MetadataAssemblyHelper.cs
- webeventbuffer.cs
- PageStatePersister.cs
- CustomError.cs
- EnumValidator.cs
- InstanceDescriptor.cs
- EditCommandColumn.cs
- ChtmlTextWriter.cs
- LinqDataSourceDisposeEventArgs.cs
- GroupBox.cs
- NumberSubstitution.cs
- CqlLexer.cs
- SuppressMessageAttribute.cs
- SocketAddress.cs
- ThreadAbortException.cs
- WindowsAuthenticationEventArgs.cs