Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / 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); } } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DoubleAnimationUsingKeyFrames.cs
- DbConnectionPoolIdentity.cs
- GraphicsState.cs
- GlyphsSerializer.cs
- MenuEventArgs.cs
- MenuBase.cs
- TextTreeText.cs
- WindowsFormsDesignerOptionService.cs
- UidPropertyAttribute.cs
- CodeDirectiveCollection.cs
- HeaderLabel.cs
- SByteStorage.cs
- OledbConnectionStringbuilder.cs
- Wizard.cs
- ReflectionUtil.cs
- MessageCredentialType.cs
- UdpMessageProperty.cs
- ProbeDuplexCD1AsyncResult.cs
- DesignerView.xaml.cs
- InfoCardAsymmetricCrypto.cs
- TemplateBindingExtensionConverter.cs
- MetadataPropertyvalue.cs
- Imaging.cs
- Configuration.cs
- __FastResourceComparer.cs
- WebPartDisplayModeEventArgs.cs
- ScopelessEnumAttribute.cs
- Array.cs
- BufferedReadStream.cs
- StorageConditionPropertyMapping.cs
- EnvelopedSignatureTransform.cs
- SqlParameterizer.cs
- DataGridViewCheckBoxCell.cs
- XmlLoader.cs
- DesignerUtils.cs
- ReplyAdapterChannelListener.cs
- DataServiceRequestException.cs
- FontInfo.cs
- InfiniteIntConverter.cs
- ToolStripDesignerAvailabilityAttribute.cs
- SmiTypedGetterSetter.cs
- BaseParser.cs
- complextypematerializer.cs
- IntSecurity.cs
- SqlCommand.cs
- PenThreadPool.cs
- SourceSwitch.cs
- WindowsEditBoxRange.cs
- ThreadSafeList.cs
- WindowsTreeView.cs
- AttributeQuery.cs
- Pkcs7Signer.cs
- OletxResourceManager.cs
- FixUpCollection.cs
- GridViewItemAutomationPeer.cs
- MimeTypeMapper.cs
- DataGridViewLayoutData.cs
- MarkupObject.cs
- HttpServerUtilityWrapper.cs
- CorePropertiesFilter.cs
- XmlILIndex.cs
- HttpCachePolicy.cs
- ToolStripSeparator.cs
- ColumnHeaderConverter.cs
- RoutingTable.cs
- RequiredFieldValidator.cs
- Regex.cs
- XmlEntity.cs
- MiniMapControl.xaml.cs
- DataViewSetting.cs
- ExtensionFile.cs
- EntityDataSourceStatementEditorForm.cs
- MetadataArtifactLoaderComposite.cs
- NegatedConstant.cs
- PrintPreviewControl.cs
- Decoder.cs
- WebPartConnectionsCancelVerb.cs
- pingexception.cs
- Ipv6Element.cs
- MultiBinding.cs
- DockPatternIdentifiers.cs
- Connector.cs
- DateTimeFormatInfoScanner.cs
- CustomAttributeSerializer.cs
- SqlParameter.cs
- HttpListenerResponse.cs
- SortAction.cs
- ClickablePoint.cs
- TextBoxBase.cs
- ExtendedTransformFactory.cs
- OleDbDataAdapter.cs
- Matrix3D.cs
- RegexCharClass.cs
- WebPartEditorApplyVerb.cs
- TargetControlTypeAttribute.cs
- ObjectDataSourceChooseMethodsPanel.cs
- formatter.cs
- SoapMessage.cs
- SessionStateItemCollection.cs
- DbException.cs