Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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); } } } // 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
- SkewTransform.cs
- SynchronizationContext.cs
- SplitterPanel.cs
- Point4D.cs
- OrderedEnumerableRowCollection.cs
- ExpressionNode.cs
- XmlCharCheckingReader.cs
- CodeTypeOfExpression.cs
- XmlRootAttribute.cs
- DBCSCodePageEncoding.cs
- SQLString.cs
- CardSpaceShim.cs
- ChannelDispatcher.cs
- GridViewCommandEventArgs.cs
- FixedTextSelectionProcessor.cs
- TemplateBindingExtensionConverter.cs
- QueryContext.cs
- WebPartExportVerb.cs
- HostedTransportConfigurationManager.cs
- HttpCookieCollection.cs
- ContextMarshalException.cs
- FtpRequestCacheValidator.cs
- FixedSOMTable.cs
- ObjectConverter.cs
- MsmqIntegrationBindingElement.cs
- Literal.cs
- NetCodeGroup.cs
- SamlAssertionKeyIdentifierClause.cs
- LinkTarget.cs
- GridItemPattern.cs
- DataSetUtil.cs
- TypeDescriptionProviderAttribute.cs
- InputScope.cs
- DataSourceCache.cs
- FlowDocumentPage.cs
- StrokeFIndices.cs
- StringComparer.cs
- PageClientProxyGenerator.cs
- RegexCompilationInfo.cs
- RemotingException.cs
- DbParameterCollectionHelper.cs
- SerializerProvider.cs
- CookieProtection.cs
- ClientSideQueueItem.cs
- FilteredDataSetHelper.cs
- ToolStripDesigner.cs
- ObjectContextServiceProvider.cs
- FunctionDescription.cs
- BlockUIContainer.cs
- IProducerConsumerCollection.cs
- WebPartAuthorizationEventArgs.cs
- DataTableReader.cs
- EmissiveMaterial.cs
- WebPartHelpVerb.cs
- DocumentViewerBase.cs
- SocketCache.cs
- GridViewDeletedEventArgs.cs
- counter.cs
- ZipArchive.cs
- GorillaCodec.cs
- SortedList.cs
- PageSetupDialog.cs
- dataprotectionpermission.cs
- SmiContext.cs
- URLEditor.cs
- FormatterConverter.cs
- RedBlackList.cs
- DbDataAdapter.cs
- CapabilitiesRule.cs
- DropDownList.cs
- PageThemeCodeDomTreeGenerator.cs
- UriTemplateTrieNode.cs
- ValidationHelpers.cs
- CodeObjectCreateExpression.cs
- ExpressionParser.cs
- QilBinary.cs
- JavaScriptString.cs
- CodeExporter.cs
- SelectionChangedEventArgs.cs
- Statements.cs
- HtmlTableRowCollection.cs
- ObjectViewQueryResultData.cs
- StdValidatorsAndConverters.cs
- DataBoundControlParameterTarget.cs
- ParseChildrenAsPropertiesAttribute.cs
- InstalledFontCollection.cs
- SecurityUniqueId.cs
- LayeredChannelFactory.cs
- Process.cs
- PolyLineSegment.cs
- ClientUtils.cs
- TemplatedEditableDesignerRegion.cs
- nulltextcontainer.cs
- FileDialogPermission.cs
- CopyOnWriteList.cs
- QueryCursorEventArgs.cs
- ConfigPathUtility.cs
- TraceContextRecord.cs
- DataReaderContainer.cs
- CryptoProvider.cs