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
- ProfileBuildProvider.cs
- IdentityNotMappedException.cs
- XmlParserContext.cs
- NativeMethods.cs
- Decorator.cs
- AppSettingsReader.cs
- ListControlActionList.cs
- MasterPageParser.cs
- ComplusTypeValidator.cs
- Latin1Encoding.cs
- BufferedStream.cs
- SmtpClient.cs
- StateWorkerRequest.cs
- ModelPerspective.cs
- SqlDependencyUtils.cs
- DocComment.cs
- Soap12FormatExtensions.cs
- StylesEditorDialog.cs
- PropertyFilterAttribute.cs
- TableCell.cs
- SimpleFileLog.cs
- Collection.cs
- EntityContainerRelationshipSet.cs
- CounterCreationData.cs
- NamespaceEmitter.cs
- BlurBitmapEffect.cs
- BitmapEffectCollection.cs
- MasterPage.cs
- SelectionChangedEventArgs.cs
- XmlSchemaObjectCollection.cs
- GeneralTransformGroup.cs
- SqlClientPermission.cs
- Graph.cs
- OleDbConnectionPoolGroupProviderInfo.cs
- XPathArrayIterator.cs
- TextMetrics.cs
- RedBlackList.cs
- TypedRowHandler.cs
- SqlGatherProducedAliases.cs
- HMACMD5.cs
- PropertyManager.cs
- StdValidatorsAndConverters.cs
- CircleHotSpot.cs
- BuildProvidersCompiler.cs
- SQLDateTimeStorage.cs
- OleDbCommand.cs
- AuthorizationSection.cs
- TypeDescriptionProvider.cs
- DataSourceProvider.cs
- IndexOutOfRangeException.cs
- userdatakeys.cs
- UserControl.cs
- GenerateHelper.cs
- wgx_sdk_version.cs
- RightsManagementLicense.cs
- XmlHierarchicalDataSourceView.cs
- RequestCachePolicyConverter.cs
- UnescapedXmlDiagnosticData.cs
- TaskFileService.cs
- Matrix.cs
- DataBoundControlDesigner.cs
- KeyPressEvent.cs
- TrustManagerMoreInformation.cs
- DataGridDesigner.cs
- FixedLineResult.cs
- Cursor.cs
- ServiceModelExtensionCollectionElement.cs
- RegistryHandle.cs
- WebServiceMethodData.cs
- ExternalCalls.cs
- TranslateTransform.cs
- AppSettingsReader.cs
- SamlDoNotCacheCondition.cs
- LZCodec.cs
- DataSysAttribute.cs
- EffectiveValueEntry.cs
- HierarchicalDataSourceIDConverter.cs
- InternalTypeHelper.cs
- NamespaceEmitter.cs
- DbCommandTree.cs
- RadioButton.cs
- SQLInt16Storage.cs
- Table.cs
- SafeLibraryHandle.cs
- BinaryFormatterWriter.cs
- RelationshipConverter.cs
- TraceSource.cs
- NotifyCollectionChangedEventArgs.cs
- AnyAllSearchOperator.cs
- LinqToSqlWrapper.cs
- ConfigPathUtility.cs
- SelectionEditingBehavior.cs
- CodeGroup.cs
- Sequence.cs
- AuthorizationSection.cs
- SyndicationElementExtensionCollection.cs
- HostElement.cs
- Wow64ConfigurationLoader.cs
- ConnectionStringsSection.cs
- HandlerFactoryWrapper.cs