Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- Clipboard.cs
- OracleRowUpdatingEventArgs.cs
- ValidateNames.cs
- RegexNode.cs
- UnsafeNativeMethods.cs
- CacheEntry.cs
- MemberInfoSerializationHolder.cs
- ThreadStateException.cs
- SqlErrorCollection.cs
- ConstructorExpr.cs
- NativeMethods.cs
- RuntimeHelpers.cs
- SqlDataSourceView.cs
- ToolstripProfessionalRenderer.cs
- SqlConnectionPoolGroupProviderInfo.cs
- PrinterSettings.cs
- TemplatingOptionsDialog.cs
- ConnectionStringSettingsCollection.cs
- GeometryDrawing.cs
- MsmqIntegrationBindingCollectionElement.cs
- ListViewItem.cs
- RectangleGeometry.cs
- VectorConverter.cs
- XmlSchemaProviderAttribute.cs
- Hex.cs
- DescendantBaseQuery.cs
- XmlHierarchyData.cs
- FileLogRecord.cs
- TraceEventCache.cs
- SiteMapNodeCollection.cs
- CommentAction.cs
- SqlCachedBuffer.cs
- Connector.cs
- validationstate.cs
- SpnEndpointIdentityExtension.cs
- PermissionAttributes.cs
- KeyedCollection.cs
- TextDpi.cs
- TextServicesCompartment.cs
- QuaternionKeyFrameCollection.cs
- TemplateAction.cs
- CachedPathData.cs
- ConstantSlot.cs
- TerminatorSinks.cs
- WebEventCodes.cs
- SinglePageViewer.cs
- FatalException.cs
- SecurityElementBase.cs
- SocketPermission.cs
- DockAndAnchorLayout.cs
- Environment.cs
- HtmlMobileTextWriter.cs
- Utils.cs
- DependsOnAttribute.cs
- DomainConstraint.cs
- MemberHolder.cs
- SerTrace.cs
- SqlDataSourceCommandParser.cs
- PageHandlerFactory.cs
- BooleanSwitch.cs
- AsyncCompletedEventArgs.cs
- AttachedPropertyBrowsableForTypeAttribute.cs
- HttpAsyncResult.cs
- Journaling.cs
- FormatConvertedBitmap.cs
- FormViewDeletedEventArgs.cs
- SchemaExporter.cs
- IdentityNotMappedException.cs
- ProjectionPruner.cs
- WindowsTitleBar.cs
- XmlILOptimizerVisitor.cs
- MoveSizeWinEventHandler.cs
- SafeHandles.cs
- DocobjHost.cs
- DbConnectionClosed.cs
- DockEditor.cs
- StrictModeSecurityHeaderElementInferenceEngine.cs
- AspNetCacheProfileAttribute.cs
- UserControlCodeDomTreeGenerator.cs
- ControlEvent.cs
- UIPermission.cs
- XdrBuilder.cs
- SubstitutionResponseElement.cs
- Monitor.cs
- SynthesizerStateChangedEventArgs.cs
- ScriptingJsonSerializationSection.cs
- KnownBoxes.cs
- CodePropertyReferenceExpression.cs
- HitTestWithPointDrawingContextWalker.cs
- FileDataSourceCache.cs
- RowToParametersTransformer.cs
- XComponentModel.cs
- XslAst.cs
- ExpandoObject.cs
- DataSet.cs
- sqlinternaltransaction.cs
- MediaPlayerState.cs
- EventLogEntryCollection.cs
- WSFederationHttpBinding.cs
- SimpleHandlerFactory.cs