Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Configuration / System / Configuration / KeyValueConfigurationElement.cs / 1305376 / KeyValueConfigurationElement.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Configuration {
using System;
using System.Xml;
using System.Configuration;
using System.Collections.Specialized;
using System.Collections;
using System.IO;
using System.Text;
public class KeyValueConfigurationElement : ConfigurationElement {
private static ConfigurationPropertyCollection _properties;
private static readonly ConfigurationProperty _propKey =
new ConfigurationProperty("key", typeof(string), String.Empty, ConfigurationPropertyOptions.IsKey | ConfigurationPropertyOptions.IsRequired);
private static readonly ConfigurationProperty _propValue =
new ConfigurationProperty("value", typeof(string), String.Empty, ConfigurationPropertyOptions.None);
static KeyValueConfigurationElement() {
// Property initialization
_properties = new ConfigurationPropertyCollection();
_properties.Add(_propKey);
_properties.Add(_propValue);
}
protected internal override ConfigurationPropertyCollection Properties {
get {
return _properties;
}
}
bool _needsInit;
string _initKey;
string _initValue;
//
// Constructor
//
internal KeyValueConfigurationElement() {
}
public KeyValueConfigurationElement(string key, string value) {
_needsInit = true;
_initKey = key;
_initValue = value;
}
protected internal override void Init() {
base.Init();
// We cannot initialize configuration properties in the constructor,
// because Properties is an overridable virtual property that
// hence may not be available in the constructor.
if (_needsInit) {
_needsInit = false;
base[_propKey] = _initKey;
Value = _initValue;
}
}
//
// Properties
//
[ConfigurationProperty("key", Options = ConfigurationPropertyOptions.IsKey, DefaultValue = "")]
public string Key {
get {
return (string)base[_propKey];
}
}
[ConfigurationProperty("value", DefaultValue = "")]
public string Value {
get {
return (string)base[_propValue];
}
set {
base[_propValue] = value;
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Configuration {
using System;
using System.Xml;
using System.Configuration;
using System.Collections.Specialized;
using System.Collections;
using System.IO;
using System.Text;
public class KeyValueConfigurationElement : ConfigurationElement {
private static ConfigurationPropertyCollection _properties;
private static readonly ConfigurationProperty _propKey =
new ConfigurationProperty("key", typeof(string), String.Empty, ConfigurationPropertyOptions.IsKey | ConfigurationPropertyOptions.IsRequired);
private static readonly ConfigurationProperty _propValue =
new ConfigurationProperty("value", typeof(string), String.Empty, ConfigurationPropertyOptions.None);
static KeyValueConfigurationElement() {
// Property initialization
_properties = new ConfigurationPropertyCollection();
_properties.Add(_propKey);
_properties.Add(_propValue);
}
protected internal override ConfigurationPropertyCollection Properties {
get {
return _properties;
}
}
bool _needsInit;
string _initKey;
string _initValue;
//
// Constructor
//
internal KeyValueConfigurationElement() {
}
public KeyValueConfigurationElement(string key, string value) {
_needsInit = true;
_initKey = key;
_initValue = value;
}
protected internal override void Init() {
base.Init();
// We cannot initialize configuration properties in the constructor,
// because Properties is an overridable virtual property that
// hence may not be available in the constructor.
if (_needsInit) {
_needsInit = false;
base[_propKey] = _initKey;
Value = _initValue;
}
}
//
// Properties
//
[ConfigurationProperty("key", Options = ConfigurationPropertyOptions.IsKey, DefaultValue = "")]
public string Key {
get {
return (string)base[_propKey];
}
}
[ConfigurationProperty("value", DefaultValue = "")]
public string Value {
get {
return (string)base[_propValue];
}
set {
base[_propValue] = value;
}
}
}
}
// 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
- DataGridViewToolTip.cs
- GridViewPageEventArgs.cs
- MutexSecurity.cs
- SQLSingle.cs
- LogConverter.cs
- UIPermission.cs
- CqlQuery.cs
- DbProviderFactories.cs
- MethodCallConverter.cs
- ReferencedType.cs
- SettingsPropertyWrongTypeException.cs
- FontInfo.cs
- StopStoryboard.cs
- ImageListUtils.cs
- PropertyMapper.cs
- MulticastNotSupportedException.cs
- InheritablePropertyChangeInfo.cs
- SettingsAttributes.cs
- XmlRawWriter.cs
- ReadOnlyDataSourceView.cs
- TrustManagerPromptUI.cs
- Utils.cs
- _NestedMultipleAsyncResult.cs
- AutoSizeComboBox.cs
- AsyncOperation.cs
- PointF.cs
- RC2CryptoServiceProvider.cs
- PersonalizableAttribute.cs
- InternalCache.cs
- Int64Converter.cs
- ScriptBehaviorDescriptor.cs
- CodeSnippetTypeMember.cs
- DataGridViewCellLinkedList.cs
- WebPartUserCapability.cs
- TextEditorContextMenu.cs
- SingleAnimationBase.cs
- OleDbFactory.cs
- ActivityExecutionContext.cs
- ComponentConverter.cs
- SqlParameter.cs
- RadioButton.cs
- PolicyLevel.cs
- FileFormatException.cs
- MaskPropertyEditor.cs
- SQLGuid.cs
- TraceProvider.cs
- ProxyAttribute.cs
- ObjectSecurity.cs
- XpsViewerException.cs
- GraphicsState.cs
- WebPartZoneBaseDesigner.cs
- TableParagraph.cs
- CryptoApi.cs
- Line.cs
- ProfessionalColorTable.cs
- MemberProjectionIndex.cs
- DetailsViewUpdatedEventArgs.cs
- CodeIdentifiers.cs
- AdPostCacheSubstitution.cs
- ColorAnimationBase.cs
- ValidatedControlConverter.cs
- Tracer.cs
- ValueConversionAttribute.cs
- DataTableReader.cs
- SerializationObjectManager.cs
- BlurBitmapEffect.cs
- SpellerInterop.cs
- Int32CollectionConverter.cs
- CheckableControlBaseAdapter.cs
- WebPartsSection.cs
- SqlMultiplexer.cs
- IISMapPath.cs
- QilLoop.cs
- uribuilder.cs
- WriteStateInfoBase.cs
- MSAAWinEventWrap.cs
- BevelBitmapEffect.cs
- ViewSimplifier.cs
- AnchoredBlock.cs
- SoapCommonClasses.cs
- ScrollBar.cs
- InternalEnumValidatorAttribute.cs
- ProviderSettings.cs
- ProviderConnectionPoint.cs
- CompiledQuery.cs
- DefaultValueTypeConverter.cs
- CommandLibraryHelper.cs
- SqlConnectionHelper.cs
- QilDataSource.cs
- OdbcConnectionStringbuilder.cs
- SoundPlayer.cs
- XmlSchemaGroup.cs
- IteratorAsyncResult.cs
- XmlDataSource.cs
- WindowPattern.cs
- CommandValueSerializer.cs
- GeneralTransformCollection.cs
- TrackingServices.cs
- StreamAsIStream.cs
- XhtmlTextWriter.cs