Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / 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();
}
}
}
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- RtfToXamlLexer.cs
- _ListenerAsyncResult.cs
- VisualStyleRenderer.cs
- ToolStripMenuItem.cs
- EntityTransaction.cs
- PriorityQueue.cs
- DbConnectionOptions.cs
- PeerTransportListenAddressValidator.cs
- TableStyle.cs
- ButtonDesigner.cs
- XmlReflectionImporter.cs
- RC2CryptoServiceProvider.cs
- _emptywebproxy.cs
- XmlStringTable.cs
- SecurityHelper.cs
- TraceData.cs
- AttachmentService.cs
- _AutoWebProxyScriptHelper.cs
- RtfControlWordInfo.cs
- ObjectDataSourceFilteringEventArgs.cs
- MD5CryptoServiceProvider.cs
- CustomPopupPlacement.cs
- ProxyWebPartConnectionCollection.cs
- TreeIterators.cs
- BufferBuilder.cs
- SiteMapSection.cs
- UrlPath.cs
- ApplicationBuildProvider.cs
- TraceLevelHelper.cs
- StylusPointProperties.cs
- SafeRightsManagementSessionHandle.cs
- Socket.cs
- CodeArgumentReferenceExpression.cs
- ResourceAssociationTypeEnd.cs
- Stroke.cs
- ResourceManager.cs
- HtmlCalendarAdapter.cs
- ExtendedProperty.cs
- HashRepartitionEnumerator.cs
- RootBrowserWindowProxy.cs
- OleDbConnectionPoolGroupProviderInfo.cs
- FtpCachePolicyElement.cs
- Comparer.cs
- TextWriterTraceListener.cs
- DataGridView.cs
- LineVisual.cs
- SpotLight.cs
- TemplateBuilder.cs
- ActivityValidator.cs
- BufferedConnection.cs
- FilterUserControlBase.cs
- TraceLevelStore.cs
- TypefaceMap.cs
- BindingExpressionUncommonField.cs
- UTF32Encoding.cs
- EntityDataSourceChangedEventArgs.cs
- FunctionUpdateCommand.cs
- Variant.cs
- ResourceType.cs
- MetadataFile.cs
- TableCell.cs
- ComplexTypeEmitter.cs
- AbsoluteQuery.cs
- GlobalItem.cs
- BitVector32.cs
- ExpressionNode.cs
- ListParaClient.cs
- TemplateBindingExtensionConverter.cs
- CounterSetInstanceCounterDataSet.cs
- Keyboard.cs
- DomainConstraint.cs
- QueryStringParameter.cs
- DataConnectionHelper.cs
- PasswordDeriveBytes.cs
- GridViewActionList.cs
- AsyncOperation.cs
- NavigateEvent.cs
- EncoderBestFitFallback.cs
- DynamicDataRouteHandler.cs
- ClockController.cs
- SchemaEntity.cs
- webclient.cs
- IsolatedStorageFileStream.cs
- RequestSecurityTokenResponseCollection.cs
- dbenumerator.cs
- IndexedString.cs
- ObjectSecurityT.cs
- XmlDesigner.cs
- ZoneLinkButton.cs
- OpenCollectionAsyncResult.cs
- ColumnMapCopier.cs
- EventDrivenDesigner.cs
- Encoding.cs
- VerificationAttribute.cs
- KeyToListMap.cs
- PassportAuthentication.cs
- ManagementEventArgs.cs
- _ScatterGatherBuffers.cs
- X509CertificateValidator.cs
- SqlConnectionHelper.cs