Code:
/ DotNET / DotNET / 8.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
- TypeUsageBuilder.cs
- Style.cs
- Grid.cs
- Cursor.cs
- EnumValAlphaComparer.cs
- BlobPersonalizationState.cs
- EdmProperty.cs
- HttpTransportBindingElement.cs
- HyperLink.cs
- ResXBuildProvider.cs
- ButtonColumn.cs
- SafeNativeMethodsCLR.cs
- TrackingMemoryStream.cs
- LinearGradientBrush.cs
- XpsFilter.cs
- Column.cs
- Misc.cs
- GlyphsSerializer.cs
- SHA1Managed.cs
- COM2AboutBoxPropertyDescriptor.cs
- RuntimeCompatibilityAttribute.cs
- _NTAuthentication.cs
- ListViewItem.cs
- indexingfiltermarshaler.cs
- NullableConverter.cs
- DataSetMappper.cs
- AngleUtil.cs
- TextContainerChangeEventArgs.cs
- ApplicationProxyInternal.cs
- WindowAutomationPeer.cs
- TreeViewImageIndexConverter.cs
- Decimal.cs
- ExtensibleClassFactory.cs
- ServiceReference.cs
- TimeSpanOrInfiniteConverter.cs
- MailWebEventProvider.cs
- CollectionDataContract.cs
- Gdiplus.cs
- ObjectFullSpanRewriter.cs
- ConfigurationSectionCollection.cs
- ObjectKeyFrameCollection.cs
- ConfigXmlWhitespace.cs
- CompiledQuery.cs
- MonikerSyntaxException.cs
- XmlSchemaObjectCollection.cs
- CatalogPartChrome.cs
- UserControlFileEditor.cs
- ResourceContainer.cs
- ClientTarget.cs
- SecurityRuntime.cs
- GridViewRow.cs
- Compiler.cs
- SHA1.cs
- ServiceHttpHandlerFactory.cs
- EnterpriseServicesHelper.cs
- ScaleTransform3D.cs
- MdiWindowListItemConverter.cs
- InfoCardTrace.cs
- ContainerActivationHelper.cs
- ClientProxyGenerator.cs
- TouchFrameEventArgs.cs
- ListDictionaryInternal.cs
- Rotation3DAnimationBase.cs
- EventBookmark.cs
- ListViewGroupConverter.cs
- NameSpaceExtractor.cs
- HttpResponse.cs
- Memoizer.cs
- ImageSourceTypeConverter.cs
- XPathNodeInfoAtom.cs
- XsdBuildProvider.cs
- TabControlCancelEvent.cs
- DesignerDataParameter.cs
- ISAPIRuntime.cs
- ErrorTolerantObjectWriter.cs
- CompilationSection.cs
- ImageCodecInfo.cs
- Rotation3DKeyFrameCollection.cs
- ProtocolsSection.cs
- Graph.cs
- DoubleAnimationBase.cs
- InitializationEventAttribute.cs
- DirtyTextRange.cs
- OverflowException.cs
- ProfileSettingsCollection.cs
- ProviderConnectionPoint.cs
- XmlHierarchicalDataSourceView.cs
- Bezier.cs
- DbMetaDataColumnNames.cs
- IntegrationExceptionEventArgs.cs
- DataGridViewCell.cs
- XD.cs
- FormViewCommandEventArgs.cs
- PTManager.cs
- PathFigureCollection.cs
- ModelPropertyCollectionImpl.cs
- Point3D.cs
- ButtonFieldBase.cs
- FtpWebRequest.cs
- SettingsContext.cs