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
- SAPIEngineTypes.cs
- EventQueueState.cs
- XmlWellformedWriter.cs
- ReadOnlyObservableCollection.cs
- SurrogateSelector.cs
- FusionWrap.cs
- RSAPKCS1KeyExchangeFormatter.cs
- ExpressionCopier.cs
- OutputCacheProfile.cs
- StylusButtonCollection.cs
- ConsoleKeyInfo.cs
- ShowExpandedMultiValueConverter.cs
- Metafile.cs
- TypeBinaryExpression.cs
- AnnotationAdorner.cs
- VersionValidator.cs
- HttpCookie.cs
- SmtpMail.cs
- DependsOnAttribute.cs
- NegationPusher.cs
- FilePresentation.cs
- RootAction.cs
- FontUnitConverter.cs
- ProfessionalColors.cs
- PolicyValidationException.cs
- SyndicationSerializer.cs
- DBPropSet.cs
- CodeCommentStatementCollection.cs
- WebPartZone.cs
- FrameworkContextData.cs
- XmlSchemaSimpleTypeList.cs
- COM2PropertyDescriptor.cs
- UnitySerializationHolder.cs
- ActivityPreviewDesigner.cs
- CheckBox.cs
- XhtmlStyleClass.cs
- ListSurrogate.cs
- GenericPrincipal.cs
- CharacterMetrics.cs
- HostSecurityManager.cs
- IsolatedStorageFilePermission.cs
- OpCellTreeNode.cs
- SystemFonts.cs
- XmlElementList.cs
- StateFinalizationActivity.cs
- CreationContext.cs
- Rotation3DKeyFrameCollection.cs
- ConditionalAttribute.cs
- AstTree.cs
- ImageListUtils.cs
- PropertyDescriptorCollection.cs
- PrePrepareMethodAttribute.cs
- StreamWriter.cs
- EasingFunctionBase.cs
- SharedDp.cs
- ListViewSelectEventArgs.cs
- Assembly.cs
- TextBoxBaseDesigner.cs
- RegistrySecurity.cs
- Content.cs
- SaveFileDialog.cs
- LinkLabel.cs
- SessionPageStateSection.cs
- ComponentGuaranteesAttribute.cs
- MenuItem.cs
- XmlNodeChangedEventArgs.cs
- BidOverLoads.cs
- Schema.cs
- RequestCachingSection.cs
- CodeMethodInvokeExpression.cs
- EntitySqlQueryBuilder.cs
- UpdateCompiler.cs
- HttpModulesSection.cs
- ExpandSegment.cs
- ProtocolViolationException.cs
- DbConnectionPoolGroup.cs
- CalendarData.cs
- TextServicesLoader.cs
- LambdaCompiler.Lambda.cs
- AnimationClockResource.cs
- ItemType.cs
- BamlLocalizationDictionary.cs
- Vector.cs
- StylusDownEventArgs.cs
- StreamGeometryContext.cs
- MemoryPressure.cs
- OleDbParameterCollection.cs
- TypedRowGenerator.cs
- NullableBoolConverter.cs
- ConfigurationManagerInternal.cs
- DesignerWidgets.cs
- TimeStampChecker.cs
- SettingsContext.cs
- ApplicationSettingsBase.cs
- TempEnvironment.cs
- ToggleProviderWrapper.cs
- SymbolUsageManager.cs
- ReaderContextStackData.cs
- SubMenuStyleCollection.cs
- AttachmentCollection.cs