Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / CompMod / System / Diagnostics / SwitchElementsCollection.cs / 1 / SwitchElementsCollection.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
using System.Configuration;
using System.Collections;
using System.Collections.Specialized;
namespace System.Diagnostics {
[ConfigurationCollection(typeof(SwitchElement))]
internal class SwitchElementsCollection : ConfigurationElementCollection {
new public SwitchElement this[string name] {
get {
return (SwitchElement) BaseGet(name);
}
}
public override ConfigurationElementCollectionType CollectionType {
get {
return ConfigurationElementCollectionType.AddRemoveClearMap;
}
}
protected override ConfigurationElement CreateNewElement() {
return new SwitchElement();
}
protected override Object GetElementKey(ConfigurationElement element) {
return ((SwitchElement) element).Name;
}
}
internal class SwitchElement : ConfigurationElement {
private static readonly ConfigurationPropertyCollection _properties;
private static readonly ConfigurationProperty _propName = new ConfigurationProperty("name", typeof(string), "", ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey);
private static readonly ConfigurationProperty _propValue = new ConfigurationProperty("value", typeof(string), null, ConfigurationPropertyOptions.IsRequired);
private Hashtable _attributes;
static SwitchElement(){
_properties = new ConfigurationPropertyCollection();
_properties.Add(_propName);
_properties.Add(_propValue);
}
public Hashtable Attributes {
get {
if (_attributes == null)
_attributes = new Hashtable(StringComparer.OrdinalIgnoreCase);
return _attributes;
}
}
[ConfigurationProperty("name", DefaultValue = "", IsRequired = true, IsKey = true)]
public string Name {
get {
return (string) this[_propName];
}
}
protected override ConfigurationPropertyCollection Properties {
get {
return _properties;
}
}
[ConfigurationProperty("value", IsRequired = true)]
public string Value {
get {
return (string) this[_propValue];
}
}
protected override bool OnDeserializeUnrecognizedAttribute(String name, String value)
{
ConfigurationProperty _propDynamic = new ConfigurationProperty(name, typeof(string), value);
_properties.Add(_propDynamic);
base[_propDynamic] = value; // Add them to the property bag
Attributes.Add(name, value);
return true;
}
internal void ResetProperties()
{
// blow away any UnrecognizedAttributes that we have deserialized earlier
if (_attributes != null) {
_attributes.Clear();
_properties.Clear();
_properties.Add(_propName);
_properties.Add(_propValue);
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
using System.Configuration;
using System.Collections;
using System.Collections.Specialized;
namespace System.Diagnostics {
[ConfigurationCollection(typeof(SwitchElement))]
internal class SwitchElementsCollection : ConfigurationElementCollection {
new public SwitchElement this[string name] {
get {
return (SwitchElement) BaseGet(name);
}
}
public override ConfigurationElementCollectionType CollectionType {
get {
return ConfigurationElementCollectionType.AddRemoveClearMap;
}
}
protected override ConfigurationElement CreateNewElement() {
return new SwitchElement();
}
protected override Object GetElementKey(ConfigurationElement element) {
return ((SwitchElement) element).Name;
}
}
internal class SwitchElement : ConfigurationElement {
private static readonly ConfigurationPropertyCollection _properties;
private static readonly ConfigurationProperty _propName = new ConfigurationProperty("name", typeof(string), "", ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey);
private static readonly ConfigurationProperty _propValue = new ConfigurationProperty("value", typeof(string), null, ConfigurationPropertyOptions.IsRequired);
private Hashtable _attributes;
static SwitchElement(){
_properties = new ConfigurationPropertyCollection();
_properties.Add(_propName);
_properties.Add(_propValue);
}
public Hashtable Attributes {
get {
if (_attributes == null)
_attributes = new Hashtable(StringComparer.OrdinalIgnoreCase);
return _attributes;
}
}
[ConfigurationProperty("name", DefaultValue = "", IsRequired = true, IsKey = true)]
public string Name {
get {
return (string) this[_propName];
}
}
protected override ConfigurationPropertyCollection Properties {
get {
return _properties;
}
}
[ConfigurationProperty("value", IsRequired = true)]
public string Value {
get {
return (string) this[_propValue];
}
}
protected override bool OnDeserializeUnrecognizedAttribute(String name, String value)
{
ConfigurationProperty _propDynamic = new ConfigurationProperty(name, typeof(string), value);
_properties.Add(_propDynamic);
base[_propDynamic] = value; // Add them to the property bag
Attributes.Add(name, value);
return true;
}
internal void ResetProperties()
{
// blow away any UnrecognizedAttributes that we have deserialized earlier
if (_attributes != null) {
_attributes.Clear();
_properties.Clear();
_properties.Add(_propName);
_properties.Add(_propValue);
}
}
}
}
// 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
- PostBackOptions.cs
- FollowerQueueCreator.cs
- DataGridViewCellStyle.cs
- DataTableMappingCollection.cs
- SID.cs
- DataContractSerializerSection.cs
- SoapSchemaExporter.cs
- SourceSwitch.cs
- Frame.cs
- EventEntry.cs
- _ContextAwareResult.cs
- ButtonField.cs
- QilReference.cs
- TextContainerChangeEventArgs.cs
- Metafile.cs
- TableCell.cs
- PagesSection.cs
- HMACSHA512.cs
- ApplicationTrust.cs
- TypeConverterHelper.cs
- FlatButtonAppearance.cs
- InsufficientMemoryException.cs
- Command.cs
- GridSplitter.cs
- InlineUIContainer.cs
- DataGridRelationshipRow.cs
- ControlPropertyNameConverter.cs
- GridSplitter.cs
- MasterPageBuildProvider.cs
- CompilationLock.cs
- SemanticKeyElement.cs
- XsltException.cs
- arc.cs
- ReliabilityContractAttribute.cs
- CookieParameter.cs
- Composition.cs
- Rectangle.cs
- TextProviderWrapper.cs
- PreservationFileWriter.cs
- ListViewInsertEventArgs.cs
- SchemaMapping.cs
- FormattedTextSymbols.cs
- KeyPullup.cs
- NameTable.cs
- MaskDescriptors.cs
- HyperLink.cs
- TypeDelegator.cs
- PrimitiveSchema.cs
- StreamedWorkflowDefinitionContext.cs
- UserControlParser.cs
- MembershipPasswordException.cs
- QilValidationVisitor.cs
- ConfigPathUtility.cs
- PointCollectionConverter.cs
- CategoryValueConverter.cs
- KnownIds.cs
- DBPropSet.cs
- TextEditorTyping.cs
- DependencyObjectPropertyDescriptor.cs
- SafePEFileHandle.cs
- ReflectionTypeLoadException.cs
- indexingfiltermarshaler.cs
- streamingZipPartStream.cs
- ObfuscationAttribute.cs
- FloaterParaClient.cs
- SymLanguageType.cs
- EncoderNLS.cs
- ValidationRule.cs
- JoinTreeNode.cs
- WmpBitmapEncoder.cs
- Item.cs
- LayoutTableCell.cs
- ExpressionParser.cs
- DataGridViewAutoSizeModeEventArgs.cs
- VectorCollectionValueSerializer.cs
- Journal.cs
- TabPage.cs
- ControlIdConverter.cs
- FrugalMap.cs
- ImageBrush.cs
- TraceSection.cs
- ArgIterator.cs
- CopyNamespacesAction.cs
- Color.cs
- TreeIterator.cs
- ScriptResourceHandler.cs
- MultipartContentParser.cs
- ProcessModuleCollection.cs
- DataColumnMapping.cs
- DataErrorValidationRule.cs
- log.cs
- RemotingServices.cs
- DifferencingCollection.cs
- SelectionPatternIdentifiers.cs
- ProviderUtil.cs
- WorkflowTraceTransfer.cs
- EnumMember.cs
- WebPartZoneCollection.cs
- ByteConverter.cs
- BuildResult.cs