Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Sys / System / Configuration / NameValueSectionHandler.cs / 1 / NameValueSectionHandler.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 /// public class NameValueSectionHandler : IConfigurationSectionHandler { const string defaultKeyAttribute = "key"; const string defaultValueAttribute = "value"; ////// public object Create(object parent, object context, XmlNode section) { return CreateStatic(parent, section, KeyAttributeName, ValueAttributeName); } internal static object CreateStatic(object parent, XmlNode section) { return CreateStatic(parent, section, defaultKeyAttribute, defaultValueAttribute); } internal static object CreateStatic(object parent, XmlNode section, string keyAttriuteName, string valueAttributeName) { ReadOnlyNameValueCollection result; // start result off as a shallow clone of the parent if (parent == null) result = new ReadOnlyNameValueCollection(StringComparer.OrdinalIgnoreCase); else { ReadOnlyNameValueCollection parentCollection = (ReadOnlyNameValueCollection)parent; result = new ReadOnlyNameValueCollection(parentCollection); } // process XML HandlerBase.CheckForUnrecognizedAttributes(section); foreach (XmlNode child in section.ChildNodes) { // skip whitespace and comments if (HandlerBase.IsIgnorableAlsoCheckForNonElement(child)) continue; // handle[To be supplied.] ///, , tags if (child.Name == "add") { String key = HandlerBase.RemoveRequiredAttribute(child, keyAttriuteName); String value = HandlerBase.RemoveRequiredAttribute(child, valueAttributeName, true/*allowEmptyString*/); HandlerBase.CheckForUnrecognizedAttributes(child); result[key] = value; } else if (child.Name == "remove") { String key = HandlerBase.RemoveRequiredAttribute(child, keyAttriuteName); HandlerBase.CheckForUnrecognizedAttributes(child); result.Remove(key); } else if (child.Name.Equals("clear")) { HandlerBase.CheckForUnrecognizedAttributes(child); result.Clear(); } else { HandlerBase.ThrowUnrecognizedElement(child); } } result.SetReadOnly(); return result; } /// /// protected virtual string KeyAttributeName { get { return defaultKeyAttribute;} } ///[To be supplied.] ////// protected virtual string ValueAttributeName { get { return defaultValueAttribute;} } } }[To be supplied.] ///
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- StyleReferenceConverter.cs
- PointCollectionValueSerializer.cs
- ApplyTemplatesAction.cs
- WebRequestModulesSection.cs
- ToolboxComponentsCreatingEventArgs.cs
- TouchesCapturedWithinProperty.cs
- RunWorkerCompletedEventArgs.cs
- PropertyDescriptorComparer.cs
- OutOfProcStateClientManager.cs
- EffectiveValueEntry.cs
- LogEntryHeaderv1Deserializer.cs
- DurableEnlistmentState.cs
- DocumentXPathNavigator.cs
- ModelTreeManager.cs
- TypeLibConverter.cs
- TabControl.cs
- DependencyStoreSurrogate.cs
- AsmxEndpointPickerExtension.cs
- DragEvent.cs
- StrokeNodeOperations2.cs
- PageParser.cs
- UpdatePanelTrigger.cs
- FtpWebResponse.cs
- Label.cs
- Helper.cs
- Sorting.cs
- Variable.cs
- dataprotectionpermission.cs
- DispatcherExceptionFilterEventArgs.cs
- Activity.cs
- PersonalizationProviderCollection.cs
- DataKey.cs
- DataGridViewElement.cs
- ClassDataContract.cs
- PhoneCall.cs
- Journaling.cs
- StickyNote.cs
- ActivityValidator.cs
- SchemaSetCompiler.cs
- ContentElement.cs
- FixedDocument.cs
- Visual.cs
- ObjectItemLoadingSessionData.cs
- GridViewRowEventArgs.cs
- XmlEventCache.cs
- XamlFilter.cs
- FatalException.cs
- DataGridViewCheckBoxCell.cs
- ConstraintCollection.cs
- Update.cs
- BitmapEffectInput.cs
- ScrollPattern.cs
- SqlProvider.cs
- ImpersonateTokenRef.cs
- OpCodes.cs
- PartialTrustVisibleAssemblyCollection.cs
- IDictionary.cs
- ProtocolsConfigurationHandler.cs
- AttachedAnnotation.cs
- FixedSOMTable.cs
- XmlEventCache.cs
- DesignerVerb.cs
- StyleCollection.cs
- SerializableAttribute.cs
- _HeaderInfo.cs
- SQLCharsStorage.cs
- TreeNodeBinding.cs
- HelloOperation11AsyncResult.cs
- XamlWriter.cs
- StorageMappingItemCollection.cs
- PersonalizationEntry.cs
- EditCommandColumn.cs
- WebPartManager.cs
- BCryptHashAlgorithm.cs
- ValuePatternIdentifiers.cs
- SystemIPGlobalProperties.cs
- SetStateDesigner.cs
- SqlFileStream.cs
- SecurityElement.cs
- UiaCoreTypesApi.cs
- TrustLevel.cs
- ConfigurationSettings.cs
- QuotedStringFormatReader.cs
- WorkItem.cs
- TypeSystemHelpers.cs
- SliderAutomationPeer.cs
- MethodBuilderInstantiation.cs
- TextTreeDeleteContentUndoUnit.cs
- Int32CollectionConverter.cs
- SmtpCommands.cs
- DataGridViewRowConverter.cs
- DictionaryEntry.cs
- QilLoop.cs
- ResourceReader.cs
- XmlSchemaParticle.cs
- Block.cs
- InnerItemCollectionView.cs
- RouteTable.cs
- EUCJPEncoding.cs
- PolicyUnit.cs