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
- AssertFilter.cs
- DataTableCollection.cs
- DrawingContextWalker.cs
- TextBox.cs
- SoapExtensionImporter.cs
- SqlClientFactory.cs
- DataTableNewRowEvent.cs
- ParallelEnumerableWrapper.cs
- Columns.cs
- EntityDesignerDataSourceView.cs
- PropertyValidationContext.cs
- HtmlPanelAdapter.cs
- GlyphingCache.cs
- TcpServerChannel.cs
- diagnosticsswitches.cs
- RightsManagementInformation.cs
- MetadataArtifactLoaderFile.cs
- ContentPlaceHolder.cs
- FontSourceCollection.cs
- TreeView.cs
- FixUpCollection.cs
- HitTestWithGeometryDrawingContextWalker.cs
- AsyncContentLoadedEventArgs.cs
- DataObjectCopyingEventArgs.cs
- SiteMapProvider.cs
- PrinterSettings.cs
- AttributeConverter.cs
- SuppressMergeCheckAttribute.cs
- ListDictionary.cs
- MemoryFailPoint.cs
- AutomationPattern.cs
- MarginCollapsingState.cs
- PrintPageEvent.cs
- SafeHandles.cs
- TdsParserStateObject.cs
- indexingfiltermarshaler.cs
- ResolveMatchesMessageCD1.cs
- WebPartCloseVerb.cs
- GlobalizationSection.cs
- SmtpTransport.cs
- TileBrush.cs
- DetailsViewInsertedEventArgs.cs
- TemplateInstanceAttribute.cs
- TemplatedWizardStep.cs
- IProvider.cs
- OleDbRowUpdatingEvent.cs
- TypeSystemProvider.cs
- ExeConfigurationFileMap.cs
- XamlWrapperReaders.cs
- MethodBuilderInstantiation.cs
- Mutex.cs
- FlowNode.cs
- GenericRootAutomationPeer.cs
- SafeNativeMethodsCLR.cs
- LinqDataSourceContextEventArgs.cs
- WCFServiceClientProxyGenerator.cs
- EntityParameterCollection.cs
- FailedToStartupUIException.cs
- FormatConvertedBitmap.cs
- UnsafeNativeMethodsTablet.cs
- UIElementParaClient.cs
- ActionFrame.cs
- AnonymousIdentificationSection.cs
- SortKey.cs
- OleDbConnectionFactory.cs
- SymLanguageVendor.cs
- SocketElement.cs
- PrePrepareMethodAttribute.cs
- LineGeometry.cs
- BrowserInteropHelper.cs
- PropertyPathConverter.cs
- ByteAnimationUsingKeyFrames.cs
- DataGridViewTextBoxEditingControl.cs
- AttributeUsageAttribute.cs
- ToolStripItemImageRenderEventArgs.cs
- ComIntegrationManifestGenerator.cs
- Helper.cs
- RuleSetDialog.Designer.cs
- AlternateViewCollection.cs
- BufferModeSettings.cs
- OutOfMemoryException.cs
- HttpProcessUtility.cs
- LongTypeConverter.cs
- PartialList.cs
- SocketInformation.cs
- X509ImageLogo.cs
- SimpleColumnProvider.cs
- ProxyManager.cs
- LogicalTreeHelper.cs
- Main.cs
- InternalReceiveMessage.cs
- TerminateWorkflow.cs
- SmtpCommands.cs
- OracleDataAdapter.cs
- AdCreatedEventArgs.cs
- DataGridViewHeaderCell.cs
- DeclaredTypeValidator.cs
- MdImport.cs
- ReachPageContentSerializer.cs
- UserInitiatedNavigationPermission.cs