Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Sys / System / Configuration / NameValueSectionHandler.cs / 1305376 / 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.] ///
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DbException.cs
- PenContexts.cs
- SrgsToken.cs
- ContainerVisual.cs
- ExeConfigurationFileMap.cs
- SkewTransform.cs
- ResourceType.cs
- X509ChainElement.cs
- DTCTransactionManager.cs
- CodeCompiler.cs
- WebPartEventArgs.cs
- DataGridState.cs
- ScrollableControl.cs
- WebException.cs
- WindowsFormsHostAutomationPeer.cs
- precedingsibling.cs
- WindowsIPAddress.cs
- ClientBuildManager.cs
- PenThreadWorker.cs
- TraceHwndHost.cs
- SerialErrors.cs
- HtmlInputRadioButton.cs
- BitmapSource.cs
- WsatEtwTraceListener.cs
- DataGridViewComponentPropertyGridSite.cs
- RequestCacheEntry.cs
- HttpTransportSecurity.cs
- WebPartEditVerb.cs
- SymbolDocumentGenerator.cs
- ListParaClient.cs
- ConfigsHelper.cs
- SqlServer2KCompatibilityAnnotation.cs
- XmlNavigatorStack.cs
- AnnotationMap.cs
- XpsPackagingPolicy.cs
- DataGridViewRowCollection.cs
- UInt32Storage.cs
- RawAppCommandInputReport.cs
- SchemaAttDef.cs
- XmlCodeExporter.cs
- TransactionManager.cs
- TriggerCollection.cs
- SvcFileManager.cs
- AutomationPropertyInfo.cs
- MetadataFile.cs
- InProcStateClientManager.cs
- MasterPageBuildProvider.cs
- SkewTransform.cs
- UInt16Storage.cs
- SqlCrossApplyToCrossJoin.cs
- PrintEvent.cs
- CodeTypeDeclarationCollection.cs
- TableItemStyle.cs
- Size.cs
- SslStream.cs
- ResXFileRef.cs
- CompareValidator.cs
- SerialReceived.cs
- BitConverter.cs
- EqualityComparer.cs
- UrlPropertyAttribute.cs
- GraphicsContainer.cs
- BatchParser.cs
- ObjectDisposedException.cs
- HotSpotCollection.cs
- ConnectionManagementSection.cs
- HttpModuleAction.cs
- CodeCastExpression.cs
- ClassValidator.cs
- UserControl.cs
- CustomValidator.cs
- ListCommandEventArgs.cs
- LongValidator.cs
- SafeCloseHandleCritical.cs
- AgileSafeNativeMemoryHandle.cs
- CodeSnippetExpression.cs
- ImageIndexEditor.cs
- XsdDuration.cs
- SQLString.cs
- EntityDesignerUtils.cs
- SequentialUshortCollection.cs
- InternalBufferOverflowException.cs
- AutomationPatternInfo.cs
- ParseChildrenAsPropertiesAttribute.cs
- _ConnectOverlappedAsyncResult.cs
- TypeDescriptor.cs
- FlowDocumentScrollViewerAutomationPeer.cs
- AutomationEventArgs.cs
- DesignOnlyAttribute.cs
- WpfMemberInvoker.cs
- PerfCounterSection.cs
- HandlerMappingMemo.cs
- PackageFilter.cs
- DataGridViewButtonCell.cs
- RowUpdatedEventArgs.cs
- SqlServices.cs
- HtmlLink.cs
- ObjectListFieldCollection.cs
- dsa.cs
- SendParametersContent.cs