Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- ComboBoxHelper.cs
- DiscreteKeyFrames.cs
- UnsettableComboBox.cs
- NumericUpDownAcceleration.cs
- ArrayConverter.cs
- DataGridViewUtilities.cs
- SchemaHelper.cs
- WeakReferenceList.cs
- BufferAllocator.cs
- SoapHttpTransportImporter.cs
- NodeInfo.cs
- BinaryUtilClasses.cs
- XsdDataContractExporter.cs
- NoPersistScope.cs
- SafeEventLogWriteHandle.cs
- ToolStripScrollButton.cs
- PropertyMapper.cs
- ActivityExecutionContextCollection.cs
- DSACryptoServiceProvider.cs
- PointAnimationBase.cs
- DataGridBoolColumn.cs
- CalendarDataBindingHandler.cs
- BitmapFrame.cs
- ListViewUpdatedEventArgs.cs
- Membership.cs
- SoapAttributeOverrides.cs
- DrawItemEvent.cs
- QilXmlReader.cs
- BuildProviderAppliesToAttribute.cs
- PersistenceTypeAttribute.cs
- Point3DValueSerializer.cs
- SafeViewOfFileHandle.cs
- TextCollapsingProperties.cs
- XmlSchemaSimpleContentRestriction.cs
- SelectedPathEditor.cs
- ListControl.cs
- GenericUriParser.cs
- ConfigurationSection.cs
- SaveWorkflowCommand.cs
- AudioException.cs
- ProgressBarRenderer.cs
- CountAggregationOperator.cs
- RefreshInfo.cs
- ProtocolViolationException.cs
- HttpApplicationStateBase.cs
- NativeMethods.cs
- CodeGen.cs
- _NetworkingPerfCounters.cs
- SubMenuStyle.cs
- SymbolPair.cs
- UserControlParser.cs
- LabelTarget.cs
- Helper.cs
- WebConfigurationManager.cs
- MasterPage.cs
- XamlStream.cs
- Pointer.cs
- X509Chain.cs
- CapabilitiesSection.cs
- CrossAppDomainChannel.cs
- DragDrop.cs
- ChtmlCommandAdapter.cs
- DivideByZeroException.cs
- RSAPKCS1SignatureFormatter.cs
- DataControlFieldHeaderCell.cs
- RunWorkerCompletedEventArgs.cs
- CharConverter.cs
- XmlSchemaRedefine.cs
- WebRequestModulesSection.cs
- BorderSidesEditor.cs
- OneWayChannelFactory.cs
- ProgressChangedEventArgs.cs
- AppDomainManager.cs
- WsdlParser.cs
- ItemsPresenter.cs
- FontWeight.cs
- SortQueryOperator.cs
- HybridWebProxyFinder.cs
- SizeChangedInfo.cs
- ClientRolePrincipal.cs
- TreeNodeClickEventArgs.cs
- GetIsBrowserClientRequest.cs
- DispatcherObject.cs
- AppDomainFactory.cs
- QueueAccessMode.cs
- DiagnosticEventProvider.cs
- _AcceptOverlappedAsyncResult.cs
- Figure.cs
- PrinterUnitConvert.cs
- XamlTemplateSerializer.cs
- LogLogRecordEnumerator.cs
- WebPartDeleteVerb.cs
- CqlParser.cs
- SafeHandles.cs
- PropertyGrid.cs
- ProcessHostMapPath.cs
- NetTcpSecurity.cs
- controlskin.cs
- XmlSchemaImport.cs
- SqlComparer.cs