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
- CodeCommentStatement.cs
- UnauthorizedAccessException.cs
- DataControlFieldCollection.cs
- rsa.cs
- JumpTask.cs
- InlineObject.cs
- InstanceDescriptor.cs
- StrongNameIdentityPermission.cs
- Lasso.cs
- SemanticBasicElement.cs
- UpdateProgress.cs
- QueryAccessibilityHelpEvent.cs
- ExpandableObjectConverter.cs
- PageCodeDomTreeGenerator.cs
- NativeMethods.cs
- HtmlValidatorAdapter.cs
- AttributeProviderAttribute.cs
- DesignerWebPartChrome.cs
- DbConnectionHelper.cs
- OutputCacheModule.cs
- KerberosTicketHashIdentifierClause.cs
- WebPartCatalogCloseVerb.cs
- TemplateContentLoader.cs
- KoreanLunisolarCalendar.cs
- cache.cs
- QilUnary.cs
- RowParagraph.cs
- TextUtf8RawTextWriter.cs
- ControlParameter.cs
- Roles.cs
- TextServicesContext.cs
- RuntimeIdentifierPropertyAttribute.cs
- EventMap.cs
- DesignerDeviceConfig.cs
- ZipPackage.cs
- HtmlTitle.cs
- BoundColumn.cs
- SecurityDescriptor.cs
- Psha1DerivedKeyGeneratorHelper.cs
- DataGridItemEventArgs.cs
- TraceContextEventArgs.cs
- LineUtil.cs
- ConditionalAttribute.cs
- SafeMILHandleMemoryPressure.cs
- LinqDataSourceDeleteEventArgs.cs
- ReadOnlyNameValueCollection.cs
- DataColumnCollection.cs
- DBDataPermissionAttribute.cs
- Compensate.cs
- SchemaTypeEmitter.cs
- SqlTopReducer.cs
- ProfileServiceManager.cs
- TimeZone.cs
- Socket.cs
- LayoutEditorPart.cs
- SrgsElement.cs
- PermissionListSet.cs
- GcSettings.cs
- PageTheme.cs
- PickDesigner.xaml.cs
- HelpInfo.cs
- RenamedEventArgs.cs
- FrameworkElement.cs
- StringPropertyBuilder.cs
- NativeRightsManagementAPIsStructures.cs
- KnownTypesHelper.cs
- Stacktrace.cs
- Semaphore.cs
- Camera.cs
- PropertyEmitter.cs
- ImageIndexEditor.cs
- DbDataRecord.cs
- LocalBuilder.cs
- CheckBoxFlatAdapter.cs
- AssertSection.cs
- Win32KeyboardDevice.cs
- EntityDataSourceWrapper.cs
- TargetConverter.cs
- IPAddressCollection.cs
- RestClientProxyHandler.cs
- SystemFonts.cs
- Int32Animation.cs
- ConditionBrowserDialog.cs
- CombinedGeometry.cs
- CommandLineParser.cs
- DefinitionUpdate.cs
- ConfigXmlText.cs
- DefaultWorkflowSchedulerService.cs
- EventManager.cs
- MTConfigUtil.cs
- OleDbParameter.cs
- XmlElementAttribute.cs
- TextSelectionProcessor.cs
- AnonymousIdentificationSection.cs
- MergablePropertyAttribute.cs
- DesignerActionPanel.cs
- ToolboxDataAttribute.cs
- HybridDictionary.cs
- XmlKeywords.cs
- DispatcherExceptionFilterEventArgs.cs