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
- ObjectStorage.cs
- UnsafeMethods.cs
- ApplicationServicesHostFactory.cs
- Matrix3DConverter.cs
- TitleStyle.cs
- DataSet.cs
- BinaryObjectReader.cs
- SnapLine.cs
- RegexTree.cs
- WebPartPersonalization.cs
- ScriptResourceInfo.cs
- XhtmlConformanceSection.cs
- RequestCacheEntry.cs
- Transactions.cs
- FilterableAttribute.cs
- XmlWriterTraceListener.cs
- CryptoHandle.cs
- XmlImplementation.cs
- ImageConverter.cs
- SqlProviderManifest.cs
- basevalidator.cs
- ContextProperty.cs
- RemoveStoryboard.cs
- AssemblyUtil.cs
- UnaryNode.cs
- ThicknessAnimationUsingKeyFrames.cs
- ConnectionStringSettingsCollection.cs
- DefaultSection.cs
- FormatterServices.cs
- FontStyle.cs
- ExceptionUtil.cs
- ViewCellSlot.cs
- XslTransform.cs
- ListControlBoundActionList.cs
- DuplexChannelBinder.cs
- CollectionViewProxy.cs
- XmlSchemaAttributeGroup.cs
- ButtonBase.cs
- PersonalizationStateInfoCollection.cs
- FormViewPagerRow.cs
- FormViewModeEventArgs.cs
- FileLevelControlBuilderAttribute.cs
- PerfCounterSection.cs
- StickyNote.cs
- ImmutableCollection.cs
- XamlInt32CollectionSerializer.cs
- DataGridAddNewRow.cs
- DesignerActionMethodItem.cs
- MachineKeySection.cs
- CompleteWizardStep.cs
- AxDesigner.cs
- KnownBoxes.cs
- IntranetCredentialPolicy.cs
- AssemblyBuilderData.cs
- TextTreeRootTextBlock.cs
- GridViewPageEventArgs.cs
- ImageField.cs
- XmlElement.cs
- NameValuePair.cs
- PathSegment.cs
- KnownColorTable.cs
- GenerateHelper.cs
- ResourceAttributes.cs
- WebServiceEnumData.cs
- NetworkInterface.cs
- HostProtectionPermission.cs
- Trace.cs
- DbParameterHelper.cs
- XmlDeclaration.cs
- SerializationHelper.cs
- SQlBooleanStorage.cs
- _emptywebproxy.cs
- KeyInfo.cs
- FrameworkName.cs
- Schedule.cs
- ScriptingSectionGroup.cs
- SqlConnectionHelper.cs
- InfoCardBinaryReader.cs
- Peer.cs
- ConnectionPoint.cs
- RecordManager.cs
- PropertyBuilder.cs
- DataPagerCommandEventArgs.cs
- ObfuscationAttribute.cs
- DictionaryEntry.cs
- ListMarkerLine.cs
- CannotUnloadAppDomainException.cs
- CollectionChange.cs
- DesignColumnCollection.cs
- WindowsListViewItem.cs
- AppDomainFactory.cs
- odbcmetadatacollectionnames.cs
- ApplicationId.cs
- XpsSerializerFactory.cs
- SpeechRecognitionEngine.cs
- Root.cs
- HtmlWindow.cs
- UpdateCommand.cs
- Invariant.cs
- PerformanceCounterLib.cs