Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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
- ZipFileInfo.cs
- DesignTimeType.cs
- UnsafeNativeMethods.cs
- FixedStringLookup.cs
- ALinqExpressionVisitor.cs
- CountAggregationOperator.cs
- XmlReturnWriter.cs
- InvokeMemberBinder.cs
- WindowsFormsSectionHandler.cs
- ExpandableObjectConverter.cs
- DecimalConstantAttribute.cs
- PasswordPropertyTextAttribute.cs
- ReflectEventDescriptor.cs
- TypeBuilder.cs
- ToolStripButton.cs
- DataGridViewDataConnection.cs
- CompilerWrapper.cs
- RadioButton.cs
- RSAOAEPKeyExchangeFormatter.cs
- ScaleTransform.cs
- InstanceKeyCollisionException.cs
- PreviewPrintController.cs
- XamlStream.cs
- SQLGuid.cs
- TraceProvider.cs
- AnimationStorage.cs
- ContextDataSourceContextData.cs
- DataRelationCollection.cs
- UntrustedRecipientException.cs
- ComboBoxRenderer.cs
- SQLChars.cs
- SimpleFieldTemplateUserControl.cs
- FormViewDeleteEventArgs.cs
- GroupItemAutomationPeer.cs
- BlockExpression.cs
- COM2FontConverter.cs
- RowVisual.cs
- DPCustomTypeDescriptor.cs
- IPEndPointCollection.cs
- ping.cs
- FormsAuthenticationEventArgs.cs
- SelectingProviderEventArgs.cs
- QuestionEventArgs.cs
- EmptyElement.cs
- NamespaceExpr.cs
- MouseWheelEventArgs.cs
- DesignerGenericWebPart.cs
- AppDomainCompilerProxy.cs
- GeometryHitTestParameters.cs
- BooleanFunctions.cs
- WeakReferenceEnumerator.cs
- MessageQueuePermissionEntry.cs
- SqlBooleanMismatchVisitor.cs
- EnumBuilder.cs
- UnionCodeGroup.cs
- ChangeNode.cs
- CreateParams.cs
- LocalIdKeyIdentifierClause.cs
- LayoutManager.cs
- WebPartVerb.cs
- ChannelSinkStacks.cs
- SQLInt32.cs
- TypeNameConverter.cs
- SelfIssuedTokenFactoryCredential.cs
- EventItfInfo.cs
- DataTableMappingCollection.cs
- System.Data_BID.cs
- NamespaceQuery.cs
- XmlUrlResolver.cs
- TextRunProperties.cs
- ISCIIEncoding.cs
- ConnectionPointCookie.cs
- TableCellAutomationPeer.cs
- EditorBrowsableAttribute.cs
- Metadata.cs
- KeyEventArgs.cs
- SecurityManager.cs
- PtsContext.cs
- GradientBrush.cs
- ISAPIWorkerRequest.cs
- MultiView.cs
- TypeInitializationException.cs
- ConnectionsZone.cs
- ToolStripDropDown.cs
- ServerIdentity.cs
- DataGridViewElement.cs
- DesignerMetadata.cs
- MultipleFilterMatchesException.cs
- RegexInterpreter.cs
- CacheSection.cs
- SecUtil.cs
- ContentFilePart.cs
- XmlSchemaValidator.cs
- path.cs
- VectorCollectionValueSerializer.cs
- XmlProcessingInstruction.cs
- StrokeNodeOperations2.cs
- SoundPlayer.cs
- ProfileServiceManager.cs
- TextDecoration.cs