Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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;} } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //[To be supplied.] ///// 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;} } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.[To be supplied.] ///
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- WebMessageFormatHelper.cs
- FormViewPagerRow.cs
- OracleColumn.cs
- DataGridItem.cs
- XmlStreamStore.cs
- CertificateManager.cs
- TableChangeProcessor.cs
- RichListBox.cs
- TextRangeBase.cs
- EntityDataSourceDataSelection.cs
- CodeIndexerExpression.cs
- HtmlTableRow.cs
- MsmqMessageSerializationFormat.cs
- bindurihelper.cs
- SqlStream.cs
- AdRotatorDesigner.cs
- EditingScopeUndoUnit.cs
- handlecollector.cs
- RMPermissions.cs
- DelegateInArgument.cs
- WebBaseEventKeyComparer.cs
- ContainerUtilities.cs
- FrameSecurityDescriptor.cs
- BinaryEditor.cs
- SqlPersonalizationProvider.cs
- TextContainerChangeEventArgs.cs
- WeakRefEnumerator.cs
- Triangle.cs
- InvalidOleVariantTypeException.cs
- SqlWebEventProvider.cs
- TcpConnectionPoolSettingsElement.cs
- GcSettings.cs
- CategoryNameCollection.cs
- ErrorItem.cs
- ZipIOCentralDirectoryFileHeader.cs
- ObjectListShowCommandsEventArgs.cs
- TemplateApplicationHelper.cs
- mediaclock.cs
- IgnoreFileBuildProvider.cs
- XPathDocumentNavigator.cs
- FontUnit.cs
- SmiEventSink_Default.cs
- CommonProperties.cs
- _FixedSizeReader.cs
- TableRowCollection.cs
- ThreadStartException.cs
- ArraySet.cs
- LoginUtil.cs
- CmsInterop.cs
- DocumentXPathNavigator.cs
- Int32RectValueSerializer.cs
- RuleSetReference.cs
- DataGridViewCellStyleChangedEventArgs.cs
- ScriptServiceAttribute.cs
- Table.cs
- PassportAuthenticationEventArgs.cs
- PerformanceCounter.cs
- StoryFragments.cs
- ExceptionUtil.cs
- FontUnit.cs
- PersonalizationAdministration.cs
- pingexception.cs
- TextEffectCollection.cs
- ResourceReferenceExpressionConverter.cs
- SqlDataSourceCache.cs
- CommonRemoteMemoryBlock.cs
- DataGridViewCellErrorTextNeededEventArgs.cs
- XmlCustomFormatter.cs
- DataErrorValidationRule.cs
- XmlSchemaSet.cs
- DescendantBaseQuery.cs
- TextEditorCopyPaste.cs
- PlainXmlDeserializer.cs
- ViewPort3D.cs
- WorkflowMarkupElementEventArgs.cs
- StringAnimationBase.cs
- DerivedKeySecurityToken.cs
- basecomparevalidator.cs
- SizeF.cs
- OletxCommittableTransaction.cs
- X509CertificateClaimSet.cs
- RenderCapability.cs
- TextBlockAutomationPeer.cs
- VisualBrush.cs
- AnimationTimeline.cs
- FlowLayout.cs
- __ComObject.cs
- WebControl.cs
- Application.cs
- Stopwatch.cs
- PeerNameRecord.cs
- SharedStream.cs
- DesignerDataStoredProcedure.cs
- UnmanagedMemoryAccessor.cs
- SchemaImporterExtensionElement.cs
- DocumentReferenceCollection.cs
- PropertyGridView.cs
- IEnumerable.cs
- TemplateBamlRecordReader.cs
- WebPartCatalogCloseVerb.cs