Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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; } } } // 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. /// ///// 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
- TabletDeviceInfo.cs
- DbUpdateCommandTree.cs
- HMACSHA512.cs
- RemoveStoryboard.cs
- DataGridColumnCollection.cs
- SecurityDescriptor.cs
- Object.cs
- RowsCopiedEventArgs.cs
- EventMappingSettings.cs
- DataGridCellEditEndingEventArgs.cs
- WebBrowsableAttribute.cs
- TaiwanCalendar.cs
- XmlTextWriter.cs
- SymbolType.cs
- CellTreeNodeVisitors.cs
- ObjectQuery.cs
- DesignOnlyAttribute.cs
- FrameworkRichTextComposition.cs
- ComponentRenameEvent.cs
- KeyGestureConverter.cs
- SqlUdtInfo.cs
- SqlPersonalizationProvider.cs
- ListViewGroupItemCollection.cs
- EdmFunctions.cs
- FileDialogCustomPlacesCollection.cs
- _NtlmClient.cs
- CreateUserWizard.cs
- HttpCapabilitiesEvaluator.cs
- ExtendedProperty.cs
- HttpConfigurationSystem.cs
- XmlCharCheckingReader.cs
- PageHandlerFactory.cs
- HostProtectionException.cs
- FileDialog_Vista.cs
- DataGridViewRowPostPaintEventArgs.cs
- Identifier.cs
- TypedTableBaseExtensions.cs
- DataSvcMapFileSerializer.cs
- ProcessHostServerConfig.cs
- UnsafeNativeMethods.cs
- TextTreeTextNode.cs
- CollectionViewGroupRoot.cs
- NativeCppClassAttribute.cs
- MasterPageParser.cs
- BaseParaClient.cs
- InputManager.cs
- MetadataCacheItem.cs
- PromptEventArgs.cs
- MinimizableAttributeTypeConverter.cs
- AssemblyNameProxy.cs
- XmlSchemaSimpleTypeRestriction.cs
- UnsafeNativeMethodsPenimc.cs
- FixedHighlight.cs
- MetadataCache.cs
- DefaultTypeArgumentAttribute.cs
- PrintDialogException.cs
- ResourceDescriptionAttribute.cs
- StrongNameMembershipCondition.cs
- ColorContextHelper.cs
- SByteConverter.cs
- CodeAttributeArgumentCollection.cs
- CheckoutException.cs
- UnmanagedMemoryStream.cs
- SecUtil.cs
- SqlStream.cs
- InfoCardListRequest.cs
- URL.cs
- ConfigurationErrorsException.cs
- ClientSettingsStore.cs
- SelectionUIHandler.cs
- DataGridRowClipboardEventArgs.cs
- RequestQueryParser.cs
- ActivityInstance.cs
- NativeMethods.cs
- DocumentSchemaValidator.cs
- SafeNativeMethods.cs
- CollectionChangeEventArgs.cs
- ModuleBuilder.cs
- Timeline.cs
- Polygon.cs
- ModuleConfigurationInfo.cs
- PropertyToken.cs
- FilteredDataSetHelper.cs
- TemplatingOptionsDialog.cs
- AffineTransform3D.cs
- Axis.cs
- XmlName.cs
- RequestCacheEntry.cs
- bindurihelper.cs
- ActiveDesignSurfaceEvent.cs
- CodeChecksumPragma.cs
- HitTestWithGeometryDrawingContextWalker.cs
- XmlDictionaryReaderQuotas.cs
- SchemaImporter.cs
- PackageProperties.cs
- DSASignatureFormatter.cs
- nulltextnavigator.cs
- entityreference_tresulttype.cs
- ConfigurationLoaderException.cs
- MinMaxParagraphWidth.cs