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
- ClassHandlersStore.cs
- NeutralResourcesLanguageAttribute.cs
- ConfigXmlText.cs
- RunInstallerAttribute.cs
- XmlSerializerSection.cs
- StrongNameUtility.cs
- SystemNetworkInterface.cs
- FirstMatchCodeGroup.cs
- Int64Animation.cs
- TreeNodeBindingCollection.cs
- Figure.cs
- WebPartHelpVerb.cs
- RouteParser.cs
- WindowsFormsLinkLabel.cs
- EditCommandColumn.cs
- UserPreferenceChangingEventArgs.cs
- BaseTemplateParser.cs
- RsaKeyGen.cs
- SvcMapFileLoader.cs
- Native.cs
- TabOrder.cs
- RegexReplacement.cs
- AspNetRouteServiceHttpHandler.cs
- BuildResult.cs
- VisualBasicReference.cs
- FormsAuthenticationModule.cs
- InternalConfigHost.cs
- ConnectionsZone.cs
- SnapLine.cs
- ProxyAttribute.cs
- WindowsPrincipal.cs
- ThreadPool.cs
- DataQuery.cs
- JournalEntryListConverter.cs
- OleDbWrapper.cs
- Point3DCollectionConverter.cs
- OutputCacheProfile.cs
- XslCompiledTransform.cs
- LostFocusEventManager.cs
- Closure.cs
- SQLDouble.cs
- ObjectToIdCache.cs
- FormsIdentity.cs
- CompositeScriptReferenceEventArgs.cs
- RecognizedAudio.cs
- SizeAnimationUsingKeyFrames.cs
- EmbeddedObject.cs
- ContainsRowNumberChecker.cs
- ValidationRuleCollection.cs
- CodeAssignStatement.cs
- SiteMapNode.cs
- ReturnValue.cs
- DataObject.cs
- PreloadHost.cs
- StoreContentChangedEventArgs.cs
- HttpHeaderCollection.cs
- IntranetCredentialPolicy.cs
- SqlAliasesReferenced.cs
- PropertyDescriptors.cs
- HttpResponseBase.cs
- MobileUITypeEditor.cs
- RegexWriter.cs
- UpdatePanelControlTrigger.cs
- PopOutPanel.cs
- FixedBufferAttribute.cs
- QilInvoke.cs
- PackageFilter.cs
- PenThreadPool.cs
- TableLayoutPanel.cs
- TemplatedAdorner.cs
- FilePresentation.cs
- FtpWebRequest.cs
- RequestQueryProcessor.cs
- RSACryptoServiceProvider.cs
- PanelDesigner.cs
- AssemblyAttributesGoHere.cs
- XsltOutput.cs
- CodeMethodInvokeExpression.cs
- Font.cs
- ToolBarTray.cs
- WebBrowsableAttribute.cs
- TreeNodeClickEventArgs.cs
- SqlDataSourceEnumerator.cs
- LineServicesRun.cs
- ThrowHelper.cs
- DataGridViewAdvancedBorderStyle.cs
- SqlBinder.cs
- CalculatedColumn.cs
- SchemaHelper.cs
- PropertyContainer.cs
- XAMLParseException.cs
- ToolStripContentPanel.cs
- ErrorWrapper.cs
- Stroke2.cs
- DataGridViewSelectedColumnCollection.cs
- BinaryFormatterWriter.cs
- SectionInformation.cs
- VisualBrush.cs
- SqlCommandBuilder.cs
- WSFederationHttpBindingElement.cs