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
- HtmlTableCell.cs
- ClientCultureInfo.cs
- IgnoreSectionHandler.cs
- TransformationRules.cs
- UserControl.cs
- UIElement3DAutomationPeer.cs
- AuthenticationModuleElementCollection.cs
- PageThemeParser.cs
- ScalarOps.cs
- ZoneButton.cs
- ListControl.cs
- UrlPath.cs
- VirtualDirectoryMappingCollection.cs
- FrameworkContentElement.cs
- DescendantBaseQuery.cs
- FixedSchema.cs
- _BufferOffsetSize.cs
- SplitterDesigner.cs
- HtmlUtf8RawTextWriter.cs
- RunWorkerCompletedEventArgs.cs
- WebServiceData.cs
- WebResourceUtil.cs
- DrawingImage.cs
- CurrencyWrapper.cs
- AnimationTimeline.cs
- DataDocumentXPathNavigator.cs
- IriParsingElement.cs
- ActivationArguments.cs
- RoleGroup.cs
- ColorIndependentAnimationStorage.cs
- XmlHierarchicalEnumerable.cs
- DbConnectionFactory.cs
- HttpRequest.cs
- QueryAccessibilityHelpEvent.cs
- EntitySet.cs
- FormatPage.cs
- ClockGroup.cs
- DurableServiceAttribute.cs
- coordinator.cs
- CodeAttributeDeclaration.cs
- ParallelTimeline.cs
- StructuralComparisons.cs
- PnrpPermission.cs
- _CookieModule.cs
- DebugTracing.cs
- SafeNativeMethods.cs
- PropertyItem.cs
- Int32Rect.cs
- BitmapEffectGeneralTransform.cs
- MappingSource.cs
- XmlAttributeAttribute.cs
- SoapEnvelopeProcessingElement.cs
- DatagridviewDisplayedBandsData.cs
- SamlConditions.cs
- RequestStatusBarUpdateEventArgs.cs
- StoreItemCollection.cs
- AnnotationResourceCollection.cs
- RenderCapability.cs
- TypeCodeDomSerializer.cs
- KeyboardEventArgs.cs
- Normalization.cs
- HierarchicalDataSourceControl.cs
- SqlParameterCollection.cs
- XmlSchemaSimpleContent.cs
- TimeSpanSecondsConverter.cs
- BaseInfoTable.cs
- AxisAngleRotation3D.cs
- ErrorRuntimeConfig.cs
- XmlConverter.cs
- precedingquery.cs
- DataTableNewRowEvent.cs
- EventProviderWriter.cs
- OleCmdHelper.cs
- BlurBitmapEffect.cs
- WebFormDesignerActionService.cs
- Int32Rect.cs
- SchemaImporterExtensionElementCollection.cs
- RuleProcessor.cs
- TabControlCancelEvent.cs
- DynamicDataResources.Designer.cs
- Keyboard.cs
- _TransmitFileOverlappedAsyncResult.cs
- TypedTableBaseExtensions.cs
- ImageMapEventArgs.cs
- PanelStyle.cs
- ActivationArguments.cs
- TagPrefixCollection.cs
- XmlReaderDelegator.cs
- BufferedGraphicsManager.cs
- DrawListViewColumnHeaderEventArgs.cs
- PersonalizationDictionary.cs
- MessageQueueException.cs
- SmtpNtlmAuthenticationModule.cs
- FontDriver.cs
- HttpProxyTransportBindingElement.cs
- EditorPart.cs
- ProgressiveCrcCalculatingStream.cs
- DataExpression.cs
- ListenerConstants.cs
- StatusBarItem.cs