Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Sys / System / Configuration / NameValueFileSectionHandler.cs / 1 / NameValueFileSectionHandler.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Configuration { using System.Configuration.Internal; using System.IO; using System.Xml; using System.Runtime.Versioning; ////// /// public class NameValueFileSectionHandler : IConfigurationSectionHandler { [ResourceExposure(ResourceScope.None)] [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)] public object Create(object parent, object configContext, XmlNode section) { object result = parent; // parse XML XmlNode fileAttribute = section.Attributes.RemoveNamedItem("file"); result = NameValueSectionHandler.CreateStatic(result, section); if (fileAttribute != null && fileAttribute.Value.Length != 0) { string filename = null; filename = fileAttribute.Value; IConfigErrorInfo configXmlNode = fileAttribute as IConfigErrorInfo; if (configXmlNode == null) { return null; } string configFile = configXmlNode.Filename; string directory = Path.GetDirectoryName(configFile); string sourceFileFullPath = Path.Combine(directory, filename); if (File.Exists(sourceFileFullPath)) { ConfigXmlDocument doc = new ConfigXmlDocument(); try { doc.Load(sourceFileFullPath); } catch (XmlException e) { throw new ConfigurationErrorsException(e.Message, e, sourceFileFullPath, e.LineNumber); } if (section.Name != doc.DocumentElement.Name) { throw new ConfigurationErrorsException( SR.GetString(SR.Config_name_value_file_section_file_invalid_root, section.Name), doc.DocumentElement); } result = NameValueSectionHandler.CreateStatic(result, doc.DocumentElement); } } return result; } } }/// This section handler allows <appSettings file="user.config" /> /// The file pointed to by the file= attribute is read as if it is /// an appSettings section in the config file. /// Note: the user.config file must have its root element match the /// section referring to it. So if appSettings has a file="user.config" /// attribute the root element in user.config must also be named appSettings. /// ///
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- XmlNamespaceMappingCollection.cs
- LayoutInformation.cs
- SortFieldComparer.cs
- FontFamily.cs
- FrameworkElementFactory.cs
- WinFormsSpinner.cs
- SqlTriggerContext.cs
- MediaElement.cs
- SemaphoreFullException.cs
- BinaryFormatterSinks.cs
- RepeaterDataBoundAdapter.cs
- MissingFieldException.cs
- BypassElementCollection.cs
- SequentialWorkflowRootDesigner.cs
- DataStreams.cs
- SourceFileBuildProvider.cs
- DateTimeConstantAttribute.cs
- Ops.cs
- IdleTimeoutMonitor.cs
- GregorianCalendar.cs
- HwndProxyElementProvider.cs
- Int64KeyFrameCollection.cs
- WebPermission.cs
- XPathNavigatorKeyComparer.cs
- RegexNode.cs
- StronglyTypedResourceBuilder.cs
- XPathDocumentIterator.cs
- ScopelessEnumAttribute.cs
- pingexception.cs
- BridgeDataReader.cs
- ExpressionsCollectionConverter.cs
- MouseDevice.cs
- EventlogProvider.cs
- CultureMapper.cs
- HtmlMeta.cs
- HttpApplication.cs
- TypeNameConverter.cs
- httpserverutility.cs
- StructuralCache.cs
- MeshGeometry3D.cs
- WpfSharedBamlSchemaContext.cs
- CodePageUtils.cs
- SqlCacheDependencyDatabaseCollection.cs
- PolicyManager.cs
- WebHttpBinding.cs
- MarkedHighlightComponent.cs
- ElementUtil.cs
- OracleRowUpdatedEventArgs.cs
- LinqToSqlWrapper.cs
- oledbmetadatacolumnnames.cs
- ZeroOpNode.cs
- serverconfig.cs
- DetailsViewUpdatedEventArgs.cs
- PageContent.cs
- SoapFault.cs
- SectionXmlInfo.cs
- SqlConnectionHelper.cs
- StringAnimationBase.cs
- ComboBoxAutomationPeer.cs
- SmiConnection.cs
- SmiMetaDataProperty.cs
- DataGridCommandEventArgs.cs
- VirtualPathProvider.cs
- ImpersonationContext.cs
- ShaperBuffers.cs
- UpdateRecord.cs
- SafeArrayRankMismatchException.cs
- RoleManagerSection.cs
- ControlParser.cs
- DashStyle.cs
- Tool.cs
- AsyncOperation.cs
- TableStyle.cs
- AttributeProviderAttribute.cs
- DateTimeFormat.cs
- HtmlUtf8RawTextWriter.cs
- NumericPagerField.cs
- CodeDirectoryCompiler.cs
- XmlArrayItemAttributes.cs
- HashCodeCombiner.cs
- QualificationDataItem.cs
- RequestReplyCorrelator.cs
- DynamicResourceExtension.cs
- RestHandlerFactory.cs
- ErrorWrapper.cs
- DiagnosticsConfigurationHandler.cs
- SeekableReadStream.cs
- Merger.cs
- XPathNodePointer.cs
- PriorityBindingExpression.cs
- SrgsGrammarCompiler.cs
- _CacheStreams.cs
- GatewayDefinition.cs
- SqlProviderManifest.cs
- RelationshipEntry.cs
- TextEndOfSegment.cs
- SecurityUtils.cs
- WebPartCollection.cs
- MulticastIPAddressInformationCollection.cs
- ClientData.cs