Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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
- UserControlParser.cs
- RewritingValidator.cs
- QilTargetType.cs
- CacheMemory.cs
- CharConverter.cs
- PostBackOptions.cs
- ServiceHostingEnvironment.cs
- BrowsableAttribute.cs
- RemoteArgument.cs
- SqlComparer.cs
- ObjectDataSource.cs
- MarkupCompiler.cs
- CachedTypeface.cs
- SqlXml.cs
- NativeRightsManagementAPIsStructures.cs
- InternalControlCollection.cs
- XmlSchemaObjectTable.cs
- Facet.cs
- CodeSnippetTypeMember.cs
- NetworkStream.cs
- RequestResizeEvent.cs
- SizeKeyFrameCollection.cs
- CharStorage.cs
- TransformerTypeCollection.cs
- HttpRawResponse.cs
- SecurityPolicySection.cs
- OdbcConnectionStringbuilder.cs
- QilBinary.cs
- FontFamily.cs
- ImpersonationContext.cs
- HMACSHA256.cs
- ProxyAttribute.cs
- CompiledQuery.cs
- NameTable.cs
- CleanUpVirtualizedItemEventArgs.cs
- UserNamePasswordValidationMode.cs
- filewebrequest.cs
- MDIWindowDialog.cs
- BitmapEffect.cs
- HttpRawResponse.cs
- Configuration.cs
- PointAnimationUsingPath.cs
- Int32CollectionConverter.cs
- DetailsViewRow.cs
- SyndicationSerializer.cs
- InternalDispatchObject.cs
- WS2007FederationHttpBinding.cs
- CommandHelpers.cs
- EntryPointNotFoundException.cs
- RunClient.cs
- DefaultParameterValueAttribute.cs
- CodeTypeParameterCollection.cs
- FontStyles.cs
- BitmapSizeOptions.cs
- SamlDoNotCacheCondition.cs
- BufferCache.cs
- TextPointer.cs
- SessionStateSection.cs
- MenuEventArgs.cs
- DataListCommandEventArgs.cs
- PropertyChange.cs
- DataBoundControlAdapter.cs
- GuidTagList.cs
- HyperLink.cs
- TypeValidationEventArgs.cs
- MgmtResManager.cs
- UserValidatedEventArgs.cs
- ObjectStateFormatter.cs
- TreeViewImageKeyConverter.cs
- ListViewHitTestInfo.cs
- SiteIdentityPermission.cs
- PathGeometry.cs
- HMACMD5.cs
- HttpCacheVary.cs
- WindowsListViewGroup.cs
- UInt64Converter.cs
- ReceiveCompletedEventArgs.cs
- SimpleWebHandlerParser.cs
- XamlInterfaces.cs
- AssociationSetMetadata.cs
- DataGridViewComboBoxColumn.cs
- DataFieldEditor.cs
- Site.cs
- XmlSchemaSimpleTypeRestriction.cs
- Size3DConverter.cs
- TdsParser.cs
- LogLogRecordEnumerator.cs
- PropertyEmitterBase.cs
- Function.cs
- MetadataFile.cs
- Types.cs
- Debugger.cs
- XmlLinkedNode.cs
- Size3D.cs
- _AcceptOverlappedAsyncResult.cs
- ExpressionNormalizer.cs
- RequestFactory.cs
- SetterBase.cs
- DataObjectCopyingEventArgs.cs
- complextypematerializer.cs