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
- SafeBitVector32.cs
- SiteMapDataSource.cs
- SamlAuthorizationDecisionClaimResource.cs
- log.cs
- SqlClientFactory.cs
- RefreshPropertiesAttribute.cs
- ClientTargetCollection.cs
- FormViewActionList.cs
- XMLSyntaxException.cs
- StickyNoteContentControl.cs
- GetWorkflowTree.cs
- FileNotFoundException.cs
- FormsAuthentication.cs
- TextTreeTextElementNode.cs
- TransportElement.cs
- XmlAnyElementAttributes.cs
- XPathAncestorQuery.cs
- DocumentReference.cs
- FileIOPermission.cs
- SmtpNetworkElement.cs
- Vector3DAnimationBase.cs
- HttpModulesSection.cs
- AstTree.cs
- XmlSignatureProperties.cs
- IndexedString.cs
- _ProxyChain.cs
- DataColumnMapping.cs
- TableLayoutPanelResizeGlyph.cs
- OutputCacheEntry.cs
- ColumnHeaderConverter.cs
- columnmapfactory.cs
- SoapExtension.cs
- NetworkStream.cs
- CellIdBoolean.cs
- TableLayoutPanel.cs
- LicenseProviderAttribute.cs
- MetabaseServerConfig.cs
- EntityKey.cs
- DispatcherOperation.cs
- BaseResourcesBuildProvider.cs
- Psha1DerivedKeyGeneratorHelper.cs
- RelationshipFixer.cs
- RubberbandSelector.cs
- MediaContextNotificationWindow.cs
- CharKeyFrameCollection.cs
- Privilege.cs
- MetabaseServerConfig.cs
- Region.cs
- TableItemPatternIdentifiers.cs
- DataSourceHelper.cs
- WsdlParser.cs
- TemplateContent.cs
- SchemaImporterExtensionElement.cs
- ArgIterator.cs
- _ConnectStream.cs
- InvalidChannelBindingException.cs
- ClientProxyGenerator.cs
- connectionpool.cs
- XmlSchemaComplexContent.cs
- ProfileProvider.cs
- BoolExpression.cs
- ToolStripContentPanelRenderEventArgs.cs
- ResourceDescriptionAttribute.cs
- SystemFonts.cs
- ItemChangedEventArgs.cs
- TextEndOfLine.cs
- EventToken.cs
- XmlBindingWorker.cs
- DataViewSettingCollection.cs
- MasterPageBuildProvider.cs
- HtmlTextArea.cs
- StateMachineDesignerPaint.cs
- ConnectionStringsExpressionBuilder.cs
- odbcmetadatacollectionnames.cs
- CharUnicodeInfo.cs
- LocationSectionRecord.cs
- VisualStyleInformation.cs
- Error.cs
- ControlPaint.cs
- ProcessInfo.cs
- UIPropertyMetadata.cs
- DispatchChannelSink.cs
- EventMappingSettingsCollection.cs
- TagNameToTypeMapper.cs
- SymbolEqualComparer.cs
- XmlValidatingReader.cs
- Win32.cs
- XmlSiteMapProvider.cs
- SecurityDescriptor.cs
- OracleTransaction.cs
- EventDescriptorCollection.cs
- ExpressionDumper.cs
- AcceleratedTokenProvider.cs
- XmlSchemaInferenceException.cs
- TextLineBreak.cs
- WebMethodAttribute.cs
- TransformerConfigurationWizardBase.cs
- XmlLoader.cs
- MissingManifestResourceException.cs
- RangeEnumerable.cs