Code:
/ 4.0 / 4.0 / untmp / 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. /// ///
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DataTemplate.cs
- XmlSerializationWriter.cs
- ElementMarkupObject.cs
- XmlDictionaryWriter.cs
- VisualStyleTypesAndProperties.cs
- XamlDesignerSerializationManager.cs
- XPathQueryGenerator.cs
- VisualBrush.cs
- AutoResetEvent.cs
- InvalidTimeZoneException.cs
- ClrPerspective.cs
- httpapplicationstate.cs
- RootCodeDomSerializer.cs
- BitmapVisualManager.cs
- DataRelationPropertyDescriptor.cs
- PropertyIDSet.cs
- WindowCollection.cs
- TemplateBamlRecordReader.cs
- ConsumerConnectionPointCollection.cs
- HitTestParameters.cs
- FileIOPermission.cs
- activationcontext.cs
- IpcClientChannel.cs
- TreeViewEvent.cs
- TextParagraphView.cs
- WpfKnownMemberInvoker.cs
- DefaultTextStore.cs
- RectangleGeometry.cs
- InputReferenceExpression.cs
- CodeTypeDeclarationCollection.cs
- NetTcpSection.cs
- DataGridViewSortCompareEventArgs.cs
- TextAutomationPeer.cs
- MetadataItemCollectionFactory.cs
- X509CertificateRecipientServiceCredential.cs
- Int32CollectionConverter.cs
- DecoderBestFitFallback.cs
- BulletDecorator.cs
- ProfileGroupSettings.cs
- TextShapeableCharacters.cs
- EntityDataSourceContainerNameConverter.cs
- BaseDataListPage.cs
- InstalledFontCollection.cs
- LambdaCompiler.Expressions.cs
- ObfuscationAttribute.cs
- RectangleGeometry.cs
- APCustomTypeDescriptor.cs
- MimeTypeAttribute.cs
- ItemChangedEventArgs.cs
- XmlSchemaSubstitutionGroup.cs
- DSASignatureDeformatter.cs
- CheckBoxStandardAdapter.cs
- SamlSerializer.cs
- JournalEntry.cs
- Inline.cs
- Context.cs
- CommandHelpers.cs
- DataTransferEventArgs.cs
- NativeStructs.cs
- CommentAction.cs
- SiteMapNodeCollection.cs
- AllMembershipCondition.cs
- ContourSegment.cs
- CancellationTokenRegistration.cs
- MsmqIntegrationAppDomainProtocolHandler.cs
- _ContextAwareResult.cs
- XsltSettings.cs
- SiteOfOriginPart.cs
- SiteMapSection.cs
- QueueException.cs
- PeerPresenceInfo.cs
- TypeSystem.cs
- FrameworkContentElementAutomationPeer.cs
- XhtmlMobileTextWriter.cs
- PropertyOverridesTypeEditor.cs
- MetricEntry.cs
- ISAPIApplicationHost.cs
- StdValidatorsAndConverters.cs
- DataControlLinkButton.cs
- WindowsFormsSynchronizationContext.cs
- EnumValidator.cs
- UserValidatedEventArgs.cs
- ParserOptions.cs
- UserControl.cs
- WebCategoryAttribute.cs
- DiscoveryClientRequestChannel.cs
- TypeConverterAttribute.cs
- WebServicesInteroperability.cs
- ListSourceHelper.cs
- ISAPIWorkerRequest.cs
- CultureTable.cs
- DeleteWorkflowOwnerCommand.cs
- TimeSpanConverter.cs
- ManagementNamedValueCollection.cs
- TemplateKey.cs
- XmlQueryStaticData.cs
- ExecutionContext.cs
- DateTimeOffsetConverter.cs
- ClusterRegistryConfigurationProvider.cs
- PermissionAttributes.cs