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
- XmlDataCollection.cs
- IUnknownConstantAttribute.cs
- SafeArrayRankMismatchException.cs
- UxThemeWrapper.cs
- TrustLevelCollection.cs
- RemoteTokenFactory.cs
- KeyEventArgs.cs
- SqlVisitor.cs
- PinProtectionHelper.cs
- ParameterEditorUserControl.cs
- mediaeventargs.cs
- TrackingStringDictionary.cs
- DefaultHttpHandler.cs
- Ops.cs
- BooleanToVisibilityConverter.cs
- EmptyEnumerator.cs
- ByteRangeDownloader.cs
- Bold.cs
- ClientTargetSection.cs
- DataGridViewCellLinkedList.cs
- MinimizableAttributeTypeConverter.cs
- OleDbFactory.cs
- DataContractSet.cs
- TableCellsCollectionEditor.cs
- ConfigurationException.cs
- GridViewPageEventArgs.cs
- SocketAddress.cs
- WindowsAuthenticationModule.cs
- WorkflowRuntimeService.cs
- UrlMappingsModule.cs
- ReadOnlyActivityGlyph.cs
- SystemWebCachingSectionGroup.cs
- RadioButtonPopupAdapter.cs
- ReadOnlyCollectionBuilder.cs
- SchemaTableOptionalColumn.cs
- ServiceReference.cs
- SamlAdvice.cs
- SizeChangedInfo.cs
- SqlDelegatedTransaction.cs
- DictionarySurrogate.cs
- HttpRuntimeSection.cs
- RoleService.cs
- XsltInput.cs
- SvcMapFileSerializer.cs
- FormViewPagerRow.cs
- ResourceManagerWrapper.cs
- relpropertyhelper.cs
- RootNamespaceAttribute.cs
- KeyedHashAlgorithm.cs
- X509Utils.cs
- SignatureToken.cs
- basevalidator.cs
- FamilyMap.cs
- DesignerLoader.cs
- MimePart.cs
- SQLSingleStorage.cs
- PointUtil.cs
- ErrorFormatter.cs
- CodeDirectiveCollection.cs
- Lease.cs
- PropertyChangedEventManager.cs
- Divide.cs
- ContentPlaceHolder.cs
- TextDecorations.cs
- XsltFunctions.cs
- CorrelationResolver.cs
- UrlAuthorizationModule.cs
- UxThemeWrapper.cs
- DebugView.cs
- ReceiveSecurityHeaderEntry.cs
- DebuggerService.cs
- StylusPointProperties.cs
- MappedMetaModel.cs
- BooleanFunctions.cs
- MemoryFailPoint.cs
- QueuePathEditor.cs
- SimpleBitVector32.cs
- EventArgs.cs
- InlinedAggregationOperatorEnumerator.cs
- EventNotify.cs
- DependencyPropertyAttribute.cs
- SmtpNtlmAuthenticationModule.cs
- SendActivity.cs
- ObjectTag.cs
- TimeSpanConverter.cs
- CacheSection.cs
- RuleSettingsCollection.cs
- CodeGenerationManager.cs
- ProcessModuleCollection.cs
- PathSegmentCollection.cs
- SslStream.cs
- InstanceCreationEditor.cs
- FSWPathEditor.cs
- UnmanagedMarshal.cs
- Table.cs
- Composition.cs
- FixedPageAutomationPeer.cs
- EventRoute.cs
- OracleCommandSet.cs
- MobileUserControlDesigner.cs