Code:
/ FX-1434 / FX-1434 / 1.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
- WebPartVerbCollection.cs
- FigureParagraph.cs
- SessionPageStatePersister.cs
- OutgoingWebResponseContext.cs
- thaishape.cs
- ModuleElement.cs
- ExtendedPropertyCollection.cs
- TrackBar.cs
- ServiceContractListItemList.cs
- ZeroOpNode.cs
- DocumentPageTextView.cs
- OrElse.cs
- Mapping.cs
- SendDesigner.xaml.cs
- SubpageParaClient.cs
- TemplateBamlRecordReader.cs
- WebExceptionStatus.cs
- ServiceDesigner.cs
- WindowsScrollBarBits.cs
- CodeTryCatchFinallyStatement.cs
- ReferentialConstraint.cs
- PresentationSource.cs
- StateRuntime.cs
- TabControl.cs
- RichTextBoxConstants.cs
- SeverityFilter.cs
- ContentPresenter.cs
- AccessedThroughPropertyAttribute.cs
- RegistryPermission.cs
- ResumeStoryboard.cs
- securitycriticaldata.cs
- ListBase.cs
- TextEditor.cs
- OverrideMode.cs
- MissingManifestResourceException.cs
- DataFormats.cs
- TrackingDataItem.cs
- DependencyPropertyChangedEventArgs.cs
- OpenTypeMethods.cs
- NameValueSectionHandler.cs
- AuthenticodeSignatureInformation.cs
- XmlSchemaCompilationSettings.cs
- SqlCommandBuilder.cs
- BamlLocalizableResourceKey.cs
- GridViewCancelEditEventArgs.cs
- FacetEnabledSchemaElement.cs
- BinaryMessageEncodingElement.cs
- ColorTransform.cs
- IssuerInformation.cs
- ProfileService.cs
- RuntimeWrappedException.cs
- _NTAuthentication.cs
- HttpRawResponse.cs
- DesignSurfaceManager.cs
- EventItfInfo.cs
- TextEncodedRawTextWriter.cs
- ContentElementAutomationPeer.cs
- MessageBox.cs
- AssociationType.cs
- StorageEntityTypeMapping.cs
- XmlCharacterData.cs
- WorkflowInstance.cs
- SessionStateContainer.cs
- UntrustedRecipientException.cs
- SecurityPermission.cs
- InstalledVoice.cs
- SessionStateModule.cs
- DynamicValidatorEventArgs.cs
- ColumnMap.cs
- Size.cs
- RedBlackList.cs
- WebRequestModuleElement.cs
- SoapCommonClasses.cs
- SectionXmlInfo.cs
- WebBrowserNavigatedEventHandler.cs
- DataTableTypeConverter.cs
- BinaryFormatterWriter.cs
- CodeTypeOfExpression.cs
- FlowDocumentFormatter.cs
- MailDefinition.cs
- CharEnumerator.cs
- ErrorFormatterPage.cs
- WindowPatternIdentifiers.cs
- XmlBinaryReader.cs
- BinHexDecoder.cs
- TableLayoutPanelDesigner.cs
- _ConnectStream.cs
- SmtpFailedRecipientsException.cs
- ClientSession.cs
- HandleCollector.cs
- DateTimeConverter.cs
- MultiBindingExpression.cs
- AlternationConverter.cs
- PolicyValidationException.cs
- GraphicsContainer.cs
- Lazy.cs
- SymbolMethod.cs
- EventLogReader.cs
- QilLiteral.cs
- RtfControlWordInfo.cs