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
- SrgsItemList.cs
- InternalRelationshipCollection.cs
- WorkflowViewManager.cs
- TypeUtils.cs
- CommandValueSerializer.cs
- columnmapfactory.cs
- Buffer.cs
- ExceptionUtil.cs
- SmiEventSink.cs
- CTreeGenerator.cs
- XmlParser.cs
- NameValueConfigurationCollection.cs
- UntrustedRecipientException.cs
- ScopeCollection.cs
- SelectionItemProviderWrapper.cs
- GeometryConverter.cs
- ItemsControlAutomationPeer.cs
- PackagingUtilities.cs
- RuntimeVariableList.cs
- XmlDomTextWriter.cs
- ActivityContext.cs
- SqlConnectionPoolProviderInfo.cs
- PackageRelationshipSelector.cs
- ComponentGlyph.cs
- ThemeInfoAttribute.cs
- DesignerWithHeader.cs
- BigInt.cs
- SelectionPatternIdentifiers.cs
- DetailsViewPageEventArgs.cs
- NetStream.cs
- MarkupObject.cs
- PenContexts.cs
- ColumnHeaderConverter.cs
- KeySplineConverter.cs
- BinaryExpression.cs
- ColorBlend.cs
- Int16AnimationBase.cs
- RoleGroup.cs
- BitmapSource.cs
- HtmlElementCollection.cs
- DoubleMinMaxAggregationOperator.cs
- RewritingSimplifier.cs
- DataGridViewButtonColumn.cs
- SessionSwitchEventArgs.cs
- SoapMessage.cs
- SqlServer2KCompatibilityAnnotation.cs
- ToolStripOverflowButton.cs
- InternalsVisibleToAttribute.cs
- AudioStateChangedEventArgs.cs
- ActiveXHost.cs
- RotateTransform.cs
- XmlFormatWriterGenerator.cs
- RadioButton.cs
- __Filters.cs
- DataStreams.cs
- RSAOAEPKeyExchangeDeformatter.cs
- SchemaCompiler.cs
- Util.cs
- XmlDesignerDataSourceView.cs
- SqlOuterApplyReducer.cs
- TitleStyle.cs
- BitmapEffect.cs
- PublishLicense.cs
- AutomationElementCollection.cs
- TemplatedMailWebEventProvider.cs
- DecimalConverter.cs
- CodeDOMUtility.cs
- Stroke2.cs
- DbConnectionOptions.cs
- Mapping.cs
- LocalIdKeyIdentifierClause.cs
- HttpProfileGroupBase.cs
- RightsManagementInformation.cs
- objectquery_tresulttype.cs
- ActivityExecutorSurrogate.cs
- SystemFonts.cs
- ColorTransformHelper.cs
- ExtentCqlBlock.cs
- EmissiveMaterial.cs
- FontCacheUtil.cs
- ToolStripItem.cs
- LineGeometry.cs
- PassportPrincipal.cs
- PageParser.cs
- MouseGestureConverter.cs
- SystemException.cs
- KeyboardEventArgs.cs
- StylusDownEventArgs.cs
- XmlDataSourceView.cs
- SqlTriggerAttribute.cs
- NamespaceList.cs
- XamlWrappingReader.cs
- DynamicContractTypeBuilder.cs
- StandardRuntimeEnumValidator.cs
- InheritanceContextChangedEventManager.cs
- InheritanceUI.cs
- ObjectToIdCache.cs
- GridViewPageEventArgs.cs
- WizardStepBase.cs
- SolidColorBrush.cs