Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Sys / System / Configuration / DictionarySectionHandler.cs / 1305376 / DictionarySectionHandler.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Configuration { using System.Collections; using System.Collections.Specialized; using System.Xml; using System.Globalization; ////// Simple dictionary config factory /// config is a dictionary mapping key->value /// /// <add key="name" value="text"> sets key=text /// <remove key="name"> removes the definition of key /// <clear> removes all definitions /// /// public class DictionarySectionHandler : IConfigurationSectionHandler { ////// Given a partially composed config object (possibly null) /// and some input from the config system, return a /// further partially composed config object /// public virtual object Create(Object parent, Object context, XmlNode section) { Hashtable res; // start res off as a shallow clone of the parent if (parent == null) res = new Hashtable(StringComparer.OrdinalIgnoreCase); else res = (Hashtable)((Hashtable)parent).Clone(); // process XML HandlerBase.CheckForUnrecognizedAttributes(section); foreach (XmlNode child in section.ChildNodes) { // skip whitespace and comments, throws if non-element if (HandlerBase.IsIgnorableAlsoCheckForNonElement(child)) continue; // handle, , tags if (child.Name == "add") { HandlerBase.CheckForChildNodes(child); String key = HandlerBase.RemoveRequiredAttribute(child, KeyAttributeName); String value; if (ValueRequired) value = HandlerBase.RemoveRequiredAttribute(child, ValueAttributeName); else value = HandlerBase.RemoveAttribute(child, ValueAttributeName); HandlerBase.CheckForUnrecognizedAttributes(child); if (value == null) value = ""; res[key] = value; } else if (child.Name == "remove") { HandlerBase.CheckForChildNodes(child); String key = HandlerBase.RemoveRequiredAttribute(child, KeyAttributeName); HandlerBase.CheckForUnrecognizedAttributes(child); res.Remove(key); } else if (child.Name.Equals("clear")) { HandlerBase.CheckForChildNodes(child); HandlerBase.CheckForUnrecognizedAttributes(child); res.Clear(); } else { HandlerBase.ThrowUnrecognizedElement(child); } } return res; } /// /// Make the name of the key attribute configurable by derived classes. /// protected virtual string KeyAttributeName { get { return "key";} } ////// Make the name of the value attribute configurable by derived classes. /// protected virtual string ValueAttributeName { get { return "value";} } // internal virtual bool ValueRequired { get { return false; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- HandleRef.cs
- CheckoutException.cs
- HttpInputStream.cs
- TypeGeneratedEventArgs.cs
- LocalizabilityAttribute.cs
- CqlIdentifiers.cs
- TcpSocketManager.cs
- CacheHelper.cs
- DbCommandDefinition.cs
- ContextMarshalException.cs
- MemberAccessException.cs
- CornerRadiusConverter.cs
- CodeChecksumPragma.cs
- XmlReader.cs
- ResourceAttributes.cs
- OptionalColumn.cs
- _AutoWebProxyScriptHelper.cs
- CommonProperties.cs
- XmlDocumentType.cs
- ObjectItemNoOpAssemblyLoader.cs
- SqlDuplicator.cs
- SecUtil.cs
- NameTable.cs
- EntityDataSource.cs
- StubHelpers.cs
- QuaternionAnimationBase.cs
- DocumentPage.cs
- SafeFileHandle.cs
- safePerfProviderHandle.cs
- OpacityConverter.cs
- CollectionType.cs
- JournalEntryStack.cs
- AnnotationAdorner.cs
- ParameterCollection.cs
- CryptoProvider.cs
- MediaTimeline.cs
- CharacterMetricsDictionary.cs
- Native.cs
- ZoneButton.cs
- XmlQueryStaticData.cs
- altserialization.cs
- StylusButtonCollection.cs
- DependencyPropertyAttribute.cs
- SQLInt32.cs
- MissingMethodException.cs
- BaseValidator.cs
- DrawingServices.cs
- CellQuery.cs
- ConstantSlot.cs
- PropertyChangedEventArgs.cs
- DictionaryBase.cs
- DataGridViewCell.cs
- FixedSOMLineCollection.cs
- XamlPathDataSerializer.cs
- FederatedMessageSecurityOverHttpElement.cs
- ClassDataContract.cs
- Compiler.cs
- ClientTargetSection.cs
- EditorOptionAttribute.cs
- HashAlgorithm.cs
- TreeNode.cs
- XmlJsonReader.cs
- _RequestCacheProtocol.cs
- IndependentAnimationStorage.cs
- ToolStripContainerActionList.cs
- Array.cs
- ExplicitDiscriminatorMap.cs
- Profiler.cs
- RuntimeConfig.cs
- XmlDictionaryReader.cs
- MenuItemCollection.cs
- OperationAbortedException.cs
- WindowsToolbarAsMenu.cs
- DummyDataSource.cs
- DataControlImageButton.cs
- ColorAnimation.cs
- LayoutTable.cs
- Drawing.cs
- SizeChangedEventArgs.cs
- XmlIlGenerator.cs
- IItemContainerGenerator.cs
- ListGeneralPage.cs
- ValidationContext.cs
- ToolStripPanel.cs
- GridViewColumnHeaderAutomationPeer.cs
- WebControlAdapter.cs
- FlowLayoutPanel.cs
- ProcessModelSection.cs
- ToolStripPanel.cs
- FormatterServices.cs
- METAHEADER.cs
- HelloOperationCD1AsyncResult.cs
- VersionedStreamOwner.cs
- AdapterSwitches.cs
- XmlSerializerNamespaces.cs
- QueueSurrogate.cs
- MenuItem.cs
- RequestQueue.cs
- ImageDrawing.cs
- StrongNameKeyPair.cs