Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Sys / System / Configuration / NameValueFileSectionHandler.cs / 1305376 / 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; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007./// 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
- SerializationInfo.cs
- HtmlTableRow.cs
- SignedInfo.cs
- FrameworkContentElementAutomationPeer.cs
- CodePrimitiveExpression.cs
- DBParameter.cs
- COM2DataTypeToManagedDataTypeConverter.cs
- PropertyPathWorker.cs
- MorphHelper.cs
- ControlDesignerState.cs
- MonthChangedEventArgs.cs
- InterleavedZipPartStream.cs
- Debug.cs
- SectionRecord.cs
- PropertyGeneratedEventArgs.cs
- Object.cs
- ProcessProtocolHandler.cs
- XsltConvert.cs
- ConfigurationCollectionAttribute.cs
- Context.cs
- TimerExtension.cs
- StateDesignerConnector.cs
- UIElement.cs
- DataColumnPropertyDescriptor.cs
- TableProviderWrapper.cs
- IdentityModelStringsVersion1.cs
- CharEnumerator.cs
- DataGridViewTextBoxColumn.cs
- XmlILIndex.cs
- CompatibleComparer.cs
- Button.cs
- UnorderedHashRepartitionStream.cs
- _IPv4Address.cs
- CipherData.cs
- SmtpReplyReader.cs
- DoubleLinkList.cs
- ISAPIWorkerRequest.cs
- UdpTransportSettingsElement.cs
- AvTrace.cs
- SkipStoryboardToFill.cs
- ScrollProperties.cs
- SHA256.cs
- UIElement.cs
- Lease.cs
- DataGridRowHeader.cs
- ViewStateModeByIdAttribute.cs
- AssemblyAttributes.cs
- InheritanceAttribute.cs
- AutomationEventArgs.cs
- WebPartUtil.cs
- DataTemplateSelector.cs
- CapiSymmetricAlgorithm.cs
- EnumMemberAttribute.cs
- safemediahandle.cs
- XmlLoader.cs
- OlePropertyStructs.cs
- DecimalConverter.cs
- FixedPageStructure.cs
- SchemaCreator.cs
- ToolConsole.cs
- FromRequest.cs
- HtmlInputControl.cs
- DispatcherOperation.cs
- QilUnary.cs
- DataConnectionHelper.cs
- TextParagraphProperties.cs
- AuthorizationSection.cs
- ExpandSegmentCollection.cs
- RegexBoyerMoore.cs
- ConfigViewGenerator.cs
- SecurityDescriptor.cs
- StreamWriter.cs
- TextEditor.cs
- MessagePropertyAttribute.cs
- BorderSidesEditor.cs
- ErrorFormatter.cs
- XmlAttributeOverrides.cs
- XsltOutput.cs
- SqlDependencyListener.cs
- DeferredSelectedIndexReference.cs
- TextRangeEdit.cs
- HuffModule.cs
- TableDetailsRow.cs
- WindowInteropHelper.cs
- CommonGetThemePartSize.cs
- HttpProcessUtility.cs
- XamlBuildTaskServices.cs
- NativeCppClassAttribute.cs
- CqlLexer.cs
- DataSpaceManager.cs
- Encoder.cs
- IncrementalCompileAnalyzer.cs
- APCustomTypeDescriptor.cs
- CheckBoxFlatAdapter.cs
- EventRoute.cs
- MappedMetaModel.cs
- SynchronizationValidator.cs
- AutomationProperty.cs
- ProtocolState.cs
- WebConfigurationManager.cs