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
- DataTemplateKey.cs
- DeclaredTypeValidatorAttribute.cs
- HtmlControlAdapter.cs
- HttpResponse.cs
- UserUseLicenseDictionaryLoader.cs
- TransactedBatchingBehavior.cs
- ErrorFormatterPage.cs
- OleDbConnection.cs
- AutomationProperty.cs
- Rights.cs
- Int16AnimationBase.cs
- PingReply.cs
- DockingAttribute.cs
- ControlEvent.cs
- SizeAnimationBase.cs
- basemetadatamappingvisitor.cs
- HttpListenerException.cs
- InvalidCastException.cs
- SqlCacheDependency.cs
- TracedNativeMethods.cs
- DataFieldConverter.cs
- AsymmetricCryptoHandle.cs
- GridViewRowPresenterBase.cs
- HttpResponseHeader.cs
- WebPartUtil.cs
- NameValueFileSectionHandler.cs
- InputLanguageEventArgs.cs
- arabicshape.cs
- DataGridParentRows.cs
- _OSSOCK.cs
- PageRequestManager.cs
- GridViewSelectEventArgs.cs
- DataGridColumnHeadersPresenter.cs
- Run.cs
- UrlParameterWriter.cs
- ListViewHitTestInfo.cs
- ClusterSafeNativeMethods.cs
- AssertSection.cs
- ResXDataNode.cs
- Matrix3D.cs
- ToggleButton.cs
- HighlightVisual.cs
- InvalidComObjectException.cs
- DataGridItemEventArgs.cs
- SecureEnvironment.cs
- WizardPanelChangingEventArgs.cs
- DatasetMethodGenerator.cs
- XmlnsCache.cs
- PropertyEntry.cs
- SplitterEvent.cs
- Unit.cs
- DependentList.cs
- BCryptNative.cs
- SafeCancelMibChangeNotify.cs
- StackBuilderSink.cs
- EntitySetBase.cs
- ControlBindingsCollection.cs
- AsymmetricAlgorithm.cs
- StorageTypeMapping.cs
- SubMenuStyle.cs
- ArrayExtension.cs
- ConnectionManagementElementCollection.cs
- SelectorItemAutomationPeer.cs
- TemplatedMailWebEventProvider.cs
- ComponentRenameEvent.cs
- CachedBitmap.cs
- X509Extension.cs
- VectorKeyFrameCollection.cs
- WebBrowserSiteBase.cs
- XmlSchemaRedefine.cs
- HtmlTableRow.cs
- _DisconnectOverlappedAsyncResult.cs
- ScriptResourceInfo.cs
- DesignTimeData.cs
- SamlAssertion.cs
- FlatButtonAppearance.cs
- FormCollection.cs
- NativeMethods.cs
- ConvertEvent.cs
- WindowHideOrCloseTracker.cs
- HostingPreferredMapPath.cs
- ChtmlTextWriter.cs
- GlyphTypeface.cs
- BorderGapMaskConverter.cs
- QueryResults.cs
- PageCatalogPart.cs
- FileDialog.cs
- TimeSpanSecondsOrInfiniteConverter.cs
- SemanticBasicElement.cs
- TextSpanModifier.cs
- ReachDocumentReferenceSerializer.cs
- ScrollableControl.cs
- DataGridViewControlCollection.cs
- ControllableStoryboardAction.cs
- DataControlLinkButton.cs
- CaseExpr.cs
- WmiEventSink.cs
- ItemMap.cs
- PreloadedPackages.cs
- URIFormatException.cs