Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / CompMod / System / Diagnostics / BooleanSwitch.cs / 1305376 / 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
- ResXBuildProvider.cs
- SafeNativeMethods.cs
- EventHandlingScope.cs
- ForceCopyBuildProvider.cs
- ConfigurationManagerHelperFactory.cs
- securitycriticaldataformultiplegetandset.cs
- BoundsDrawingContextWalker.cs
- EntityObject.cs
- CryptoApi.cs
- Operator.cs
- Operand.cs
- UnsafeNativeMethods.cs
- SliderAutomationPeer.cs
- LocatorPart.cs
- SpeechUI.cs
- ReferenceAssemblyAttribute.cs
- SqlUserDefinedTypeAttribute.cs
- SmiEventSink.cs
- X509AsymmetricSecurityKey.cs
- ToolStripTextBox.cs
- StringDictionaryWithComparer.cs
- HttpResponseHeader.cs
- ProcessModelInfo.cs
- EnvironmentPermission.cs
- RoleManagerEventArgs.cs
- ToolStripPanelRenderEventArgs.cs
- WpfSharedXamlSchemaContext.cs
- HttpConfigurationSystem.cs
- _Rfc2616CacheValidators.cs
- ImageMapEventArgs.cs
- OleDbCommand.cs
- IHttpResponseInternal.cs
- ProviderException.cs
- UnknownMessageReceivedEventArgs.cs
- HttpConfigurationContext.cs
- XhtmlBasicTextViewAdapter.cs
- XmlSchemaAttribute.cs
- StaticContext.cs
- HttpFileCollection.cs
- ConfigurationManager.cs
- PrintEvent.cs
- HMACSHA1.cs
- SymDocumentType.cs
- AssemblyEvidenceFactory.cs
- OrderByLifter.cs
- SiteMapNodeCollection.cs
- PropertyCondition.cs
- StylusCaptureWithinProperty.cs
- TableLayout.cs
- Rect3DConverter.cs
- GenericsInstances.cs
- QilTargetType.cs
- CompilerTypeWithParams.cs
- RC2CryptoServiceProvider.cs
- NameObjectCollectionBase.cs
- PhonemeEventArgs.cs
- SubclassTypeValidator.cs
- WriterOutput.cs
- XmlBoundElement.cs
- SqlConnectionPoolGroupProviderInfo.cs
- RepeatButtonAutomationPeer.cs
- FixedDocumentSequencePaginator.cs
- ModifiableIteratorCollection.cs
- VolatileResourceManager.cs
- HtmlHistory.cs
- SizeValueSerializer.cs
- OrCondition.cs
- WebPartConnection.cs
- GradientStop.cs
- ExtendedProperty.cs
- XmlnsCache.cs
- BackStopAuthenticationModule.cs
- ScrollItemPatternIdentifiers.cs
- RegexGroupCollection.cs
- EventItfInfo.cs
- NetPipeSection.cs
- ArrayWithOffset.cs
- DataReaderContainer.cs
- ObjectDataSourceChooseTypePanel.cs
- TcpChannelFactory.cs
- ColorInterpolationModeValidation.cs
- TextComposition.cs
- PenLineCapValidation.cs
- ListBindingConverter.cs
- KnowledgeBase.cs
- StylusSystemGestureEventArgs.cs
- FixedDocument.cs
- SecurityCapabilities.cs
- ValidatedControlConverter.cs
- SafeHandles.cs
- WorkflowFormatterBehavior.cs
- ISAPIApplicationHost.cs
- TextTreePropertyUndoUnit.cs
- Facet.cs
- DelegatedStream.cs
- FocusWithinProperty.cs
- MinimizableAttributeTypeConverter.cs
- FormViewRow.cs
- ConnectionInterfaceCollection.cs
- ProcessHostFactoryHelper.cs