Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / CompMod / System / Diagnostics / BooleanSwitch.cs / 1 / BooleanSwitch.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
/*
*/
namespace System.Diagnostics {
using System.Diagnostics;
using System;
using System.Security;
using System.Security.Permissions;
///
/// Provides a simple on/off switch that can be used to control debugging and tracing
/// output.
///
[SwitchLevel(typeof(bool))]
public class BooleanSwitch : Switch {
///
/// Initializes a new instance of the
/// class.
///
public BooleanSwitch(string displayName, string description)
: base(displayName, description) {
}
public BooleanSwitch(string displayName, string description, string defaultSwitchValue)
: base(displayName, description, defaultSwitchValue) { }
///
/// Specifies whether the switch is enabled
/// ( ) or disabled ( ).
///
public bool Enabled {
get {
return (SwitchSetting == 0) ? false : true;
}
[SecurityPermission(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.UnmanagedCode)]
set {
SwitchSetting = value ? 1 : 0;
}
}
protected override void OnValueChanged() {
bool b;
if (Boolean.TryParse(Value, out b))
SwitchSetting = ( b ? 1 : 0);
else
base.OnValueChanged();
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
/*
*/
namespace System.Diagnostics {
using System.Diagnostics;
using System;
using System.Security;
using System.Security.Permissions;
///
/// Provides a simple on/off switch that can be used to control debugging and tracing
/// output.
///
[SwitchLevel(typeof(bool))]
public class BooleanSwitch : Switch {
///
/// Initializes a new instance of the
/// class.
///
public BooleanSwitch(string displayName, string description)
: base(displayName, description) {
}
public BooleanSwitch(string displayName, string description, string defaultSwitchValue)
: base(displayName, description, defaultSwitchValue) { }
///
/// Specifies whether the switch is enabled
/// ( ) or disabled ( ).
///
public bool Enabled {
get {
return (SwitchSetting == 0) ? false : true;
}
[SecurityPermission(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.UnmanagedCode)]
set {
SwitchSetting = value ? 1 : 0;
}
}
protected override void OnValueChanged() {
bool b;
if (Boolean.TryParse(Value, out b))
SwitchSetting = ( b ? 1 : 0);
else
base.OnValueChanged();
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- InheritanceRules.cs
- EntityClientCacheEntry.cs
- DataGridViewCellEventArgs.cs
- SessionState.cs
- ConfigurationValidatorBase.cs
- DebuggerService.cs
- UInt16Storage.cs
- SignatureResourcePool.cs
- AutomationPeer.cs
- Char.cs
- OutputCacheProfile.cs
- ProxyWebPartManager.cs
- RefreshPropertiesAttribute.cs
- RayMeshGeometry3DHitTestResult.cs
- XmlBinaryReader.cs
- ThreadAbortException.cs
- InvalidProgramException.cs
- WindowsListViewGroup.cs
- PersonalizationStateQuery.cs
- MouseGesture.cs
- BuildResult.cs
- ModelTypeConverter.cs
- odbcmetadatacollectionnames.cs
- NetworkCredential.cs
- QilChoice.cs
- FormsAuthenticationEventArgs.cs
- Soap.cs
- UIElementCollection.cs
- GlyphCache.cs
- HttpFileCollection.cs
- PairComparer.cs
- OracleLob.cs
- QueryCacheManager.cs
- WindowsTitleBar.cs
- StrongNameUtility.cs
- XmlSchemaAny.cs
- RouteValueExpressionBuilder.cs
- PerformanceCounterPermissionEntryCollection.cs
- TextFormatterImp.cs
- SubordinateTransaction.cs
- x509utils.cs
- DynamicILGenerator.cs
- ValueQuery.cs
- Section.cs
- DataSetMappper.cs
- RouteParametersHelper.cs
- Number.cs
- WindowsListViewGroup.cs
- BitmapFrameDecode.cs
- LineGeometry.cs
- HyperLink.cs
- _WinHttpWebProxyDataBuilder.cs
- DateTimeFormatInfoScanner.cs
- StackSpiller.Temps.cs
- PackageRelationshipCollection.cs
- SoapAttributeOverrides.cs
- TypeSystemHelpers.cs
- FrameworkTextComposition.cs
- CodeExporter.cs
- WorkflowApplicationUnloadedException.cs
- ToolStripPanelCell.cs
- ClusterRegistryConfigurationProvider.cs
- AssemblyHash.cs
- MsmqBindingElementBase.cs
- cookieexception.cs
- SafeFileMapViewHandle.cs
- EntityClassGenerator.cs
- TableHeaderCell.cs
- XmlIlGenerator.cs
- ObjectHandle.cs
- SinglePageViewer.cs
- Encoder.cs
- MultiAsyncResult.cs
- TypeResolver.cs
- HtmlValidatorAdapter.cs
- EventsTab.cs
- PiiTraceSource.cs
- EnumBuilder.cs
- AppDomainAttributes.cs
- DesignTable.cs
- XmlNodeChangedEventArgs.cs
- TypedRowGenerator.cs
- EntityDataSourceChangingEventArgs.cs
- MouseEvent.cs
- GB18030Encoding.cs
- TabControlAutomationPeer.cs
- StringKeyFrameCollection.cs
- Application.cs
- DefaultClaimSet.cs
- WebPartDescriptionCollection.cs
- ObjectHandle.cs
- SoapAttributes.cs
- ValidatedMobileControlConverter.cs
- OleDbError.cs
- FullTrustAssemblyCollection.cs
- DataControlCommands.cs
- DataContext.cs
- AttachmentCollection.cs
- ComplexBindingPropertiesAttribute.cs
- ObjectDataSourceMethodEventArgs.cs