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
- GlyphsSerializer.cs
- RIPEMD160Managed.cs
- NotFiniteNumberException.cs
- CommandDevice.cs
- MediaContextNotificationWindow.cs
- Single.cs
- ScrollProviderWrapper.cs
- ModuleBuilderData.cs
- EventItfInfo.cs
- Mutex.cs
- CustomCategoryAttribute.cs
- InputMethod.cs
- ArraySubsetEnumerator.cs
- UnsafeNativeMethodsPenimc.cs
- PointCollection.cs
- Predicate.cs
- Label.cs
- CompilerErrorCollection.cs
- SafeCoTaskMem.cs
- TextComposition.cs
- XPathNavigatorKeyComparer.cs
- DataGridViewCheckBoxCell.cs
- TracingConnectionInitiator.cs
- WindowsTab.cs
- Dynamic.cs
- DataRelationCollection.cs
- KeyboardInputProviderAcquireFocusEventArgs.cs
- MaskedTextBoxTextEditorDropDown.cs
- NavigationEventArgs.cs
- Win32.cs
- COM2DataTypeToManagedDataTypeConverter.cs
- HotSpotCollection.cs
- CheckBoxList.cs
- LongCountAggregationOperator.cs
- baseaxisquery.cs
- MenuItemCollection.cs
- _AutoWebProxyScriptHelper.cs
- RegexMatch.cs
- ColumnMap.cs
- StrokeCollection2.cs
- Input.cs
- DoubleAnimationBase.cs
- StylusEditingBehavior.cs
- SvcMapFileLoader.cs
- IntersectQueryOperator.cs
- RtfFormatStack.cs
- PersonalizationEntry.cs
- Vector3D.cs
- TextLine.cs
- WmlListAdapter.cs
- ProofTokenCryptoHandle.cs
- MailSettingsSection.cs
- HttpCacheVaryByContentEncodings.cs
- Setter.cs
- backend.cs
- TrackingParameters.cs
- figurelengthconverter.cs
- XpsTokenContext.cs
- MulticastNotSupportedException.cs
- XmlArrayAttribute.cs
- RectConverter.cs
- SelectionListComponentEditor.cs
- HandlerFactoryCache.cs
- SpeakCompletedEventArgs.cs
- DocumentSequence.cs
- TextAutomationPeer.cs
- StreamSecurityUpgradeInitiator.cs
- AssociationType.cs
- ServiceDesigner.cs
- ListViewDeletedEventArgs.cs
- DragCompletedEventArgs.cs
- DbConvert.cs
- LambdaExpression.cs
- ServiceModelConfigurationSectionGroup.cs
- Visual3DCollection.cs
- XmlHierarchyData.cs
- IsolatedStorageException.cs
- ListViewHitTestInfo.cs
- VideoDrawing.cs
- StrokeFIndices.cs
- ByteKeyFrameCollection.cs
- XmlSchemaDatatype.cs
- BindingsCollection.cs
- KnowledgeBase.cs
- ArrayWithOffset.cs
- PropertyKey.cs
- isolationinterop.cs
- ProxyWebPartManager.cs
- ObjectStateManagerMetadata.cs
- XmlnsCache.cs
- FastPropertyAccessor.cs
- ResourceReferenceExpressionConverter.cs
- AxisAngleRotation3D.cs
- LogicalTreeHelper.cs
- SearchForVirtualItemEventArgs.cs
- Page.cs
- CodeDirectoryCompiler.cs
- ControlDesigner.cs
- WebPartTransformer.cs
- SqlMethodAttribute.cs