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
- linebase.cs
- GlyphRun.cs
- CodeAccessSecurityEngine.cs
- EncodingNLS.cs
- panel.cs
- XPathSingletonIterator.cs
- TextMetrics.cs
- RectangleGeometry.cs
- TransformerConfigurationWizardBase.cs
- IriParsingElement.cs
- If.cs
- ExpandCollapseProviderWrapper.cs
- PropertyCondition.cs
- DockPattern.cs
- FormatterServices.cs
- RuntimeConfig.cs
- QueryOperationResponseOfT.cs
- HttpServerVarsCollection.cs
- InlineObject.cs
- DataGridViewLayoutData.cs
- DataBinding.cs
- PasswordDeriveBytes.cs
- TextElement.cs
- ProgressPage.cs
- SettingsBindableAttribute.cs
- ViewCellRelation.cs
- LeaseManager.cs
- PaintValueEventArgs.cs
- FusionWrap.cs
- SqlRetyper.cs
- Missing.cs
- SmtpCommands.cs
- MasterPageCodeDomTreeGenerator.cs
- EventLogPermissionEntry.cs
- InternalConfirm.cs
- XmlSchemaComplexContentExtension.cs
- SoapProtocolReflector.cs
- ADMembershipProvider.cs
- BooleanAnimationUsingKeyFrames.cs
- XamlSerializer.cs
- PropertyChangedEventManager.cs
- ConstraintConverter.cs
- Label.cs
- webclient.cs
- Type.cs
- SerialReceived.cs
- DataGridParentRows.cs
- DesignTimeTemplateParser.cs
- DataSourceIDConverter.cs
- TagPrefixCollection.cs
- StoragePropertyMapping.cs
- XPathBinder.cs
- HwndSubclass.cs
- TraceHandler.cs
- PathFigureCollectionValueSerializer.cs
- DataObjectEventArgs.cs
- StatusBarDrawItemEvent.cs
- ErrorFormatter.cs
- GorillaCodec.cs
- loginstatus.cs
- EntityCommandDefinition.cs
- CodeArgumentReferenceExpression.cs
- SortableBindingList.cs
- CompiledAction.cs
- DocumentGridContextMenu.cs
- SqlDataSourceCommandParser.cs
- WizardStepBase.cs
- ToolStripCustomTypeDescriptor.cs
- ImageFormat.cs
- ECDiffieHellmanCngPublicKey.cs
- MembershipSection.cs
- JournalNavigationScope.cs
- StringStorage.cs
- HtmlGenericControl.cs
- EmptyImpersonationContext.cs
- StrongNameMembershipCondition.cs
- EntitySqlQueryState.cs
- RadioButtonList.cs
- SqlResolver.cs
- StringFunctions.cs
- _SSPISessionCache.cs
- ProtocolElementCollection.cs
- OutputScopeManager.cs
- XmlSerializationGeneratedCode.cs
- Int32Converter.cs
- FigureParaClient.cs
- WinEventHandler.cs
- AttributeEmitter.cs
- DataGridColumnStyleMappingNameEditor.cs
- AuthorizationRule.cs
- CodeConditionStatement.cs
- ImageListImageEditor.cs
- InternalControlCollection.cs
- SubclassTypeValidator.cs
- NonPrimarySelectionGlyph.cs
- ArrangedElementCollection.cs
- AddInAttribute.cs
- VSWCFServiceContractGenerator.cs
- ButtonBase.cs
- HttpCapabilitiesBase.cs