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
- CurrentChangingEventArgs.cs
- PropertyValue.cs
- Misc.cs
- PeerApplicationLaunchInfo.cs
- AccessedThroughPropertyAttribute.cs
- Identifier.cs
- ISessionStateStore.cs
- xsdvalidator.cs
- Cursor.cs
- Function.cs
- ActivityXRefPropertyEditor.cs
- SplineKeyFrames.cs
- DefinitionBase.cs
- FileSystemWatcher.cs
- GridViewColumnHeader.cs
- WebEvents.cs
- AttributeCollection.cs
- XmlValidatingReaderImpl.cs
- PageEventArgs.cs
- DSASignatureDeformatter.cs
- ButtonBase.cs
- DoubleCollectionConverter.cs
- KnownColorTable.cs
- XmlSchemaAttributeGroupRef.cs
- ExtensionSimplifierMarkupObject.cs
- Vector3DValueSerializer.cs
- Int64.cs
- DataGridViewCellLinkedList.cs
- FeatureSupport.cs
- NotFiniteNumberException.cs
- FontSource.cs
- DynamicPropertyHolder.cs
- MethodBody.cs
- AsyncDataRequest.cs
- NotifyInputEventArgs.cs
- QuaternionAnimation.cs
- PngBitmapEncoder.cs
- UnsafeNativeMethodsCLR.cs
- ProfileGroupSettings.cs
- MissingMemberException.cs
- AsyncOperationManager.cs
- ParagraphVisual.cs
- GPRECT.cs
- HostProtectionPermission.cs
- DataGridDesigner.cs
- Point3DCollection.cs
- TreeViewDataItemAutomationPeer.cs
- SqlTransaction.cs
- PageSettings.cs
- XmlAttributeAttribute.cs
- RegexWriter.cs
- SqlWebEventProvider.cs
- View.cs
- MsmqIntegrationProcessProtocolHandler.cs
- EventBuilder.cs
- CorrelationTokenInvalidatedHandler.cs
- EmptyControlCollection.cs
- _SSPIWrapper.cs
- WorkflowInvoker.cs
- ReceiveMessageContent.cs
- RegexCompilationInfo.cs
- ListViewDeletedEventArgs.cs
- MatrixAnimationUsingPath.cs
- ComplexBindingPropertiesAttribute.cs
- RoutedEvent.cs
- ToolStripArrowRenderEventArgs.cs
- CheckBoxPopupAdapter.cs
- CreateCardRequest.cs
- FileUtil.cs
- NetStream.cs
- WebControl.cs
- UdpTransportSettings.cs
- SqlDataSourceCache.cs
- WebPartsSection.cs
- ScriptingJsonSerializationSection.cs
- ClipboardData.cs
- DbConnectionInternal.cs
- X509SubjectKeyIdentifierClause.cs
- ContentElementAutomationPeer.cs
- QilSortKey.cs
- Ipv6Element.cs
- TextTreeTextNode.cs
- OptimalTextSource.cs
- EmptyStringExpandableObjectConverter.cs
- _NegoState.cs
- ExchangeUtilities.cs
- AnchorEditor.cs
- ConfigPathUtility.cs
- SchemaNames.cs
- ControlBindingsCollection.cs
- TextBox.cs
- GenericQueueSurrogate.cs
- TableItemProviderWrapper.cs
- EventMap.cs
- StateRuntime.cs
- AccessDataSourceView.cs
- XComponentModel.cs
- Style.cs
- FirstMatchCodeGroup.cs
- EmptyQuery.cs