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
- CustomCategoryAttribute.cs
- TypeElement.cs
- HtmlSelect.cs
- SRGSCompiler.cs
- HostingPreferredMapPath.cs
- TextTreeInsertUndoUnit.cs
- BinaryReader.cs
- ResourceExpression.cs
- SerializerDescriptor.cs
- BrushValueSerializer.cs
- BaseCAMarshaler.cs
- MexHttpBindingElement.cs
- ContractReference.cs
- DropAnimation.xaml.cs
- Msmq4PoisonHandler.cs
- ProtectedConfigurationProviderCollection.cs
- DbConnectionStringCommon.cs
- FormsIdentity.cs
- XomlCompilerHelpers.cs
- HtmlTextArea.cs
- XmlResolver.cs
- FileDialogPermission.cs
- ResourceDisplayNameAttribute.cs
- SiteMapPath.cs
- ThreadBehavior.cs
- WpfGeneratedKnownTypes.cs
- JoinSymbol.cs
- PathFigure.cs
- NamespaceList.cs
- EventHandlingScope.cs
- AuthenticatedStream.cs
- CacheVirtualItemsEvent.cs
- ThrowOnMultipleAssignment.cs
- MonikerHelper.cs
- PersonalizableAttribute.cs
- DateTimeFormatInfoScanner.cs
- WebContext.cs
- WebPartTransformerAttribute.cs
- HighlightVisual.cs
- RelationshipType.cs
- WindowsScrollBar.cs
- FontUnitConverter.cs
- FillBehavior.cs
- ObjectListCommandsPage.cs
- Cursor.cs
- IisTraceListener.cs
- Membership.cs
- ChineseLunisolarCalendar.cs
- ImageClickEventArgs.cs
- WasAdminWrapper.cs
- DataGridViewRowsAddedEventArgs.cs
- FixedSOMTableCell.cs
- DrawingContextWalker.cs
- SecureConversationDriver.cs
- MethodBuilder.cs
- ClientSponsor.cs
- ToolStripPanel.cs
- ButtonStandardAdapter.cs
- XmlAttribute.cs
- ReaderOutput.cs
- DiscoveryVersionConverter.cs
- XsdCachingReader.cs
- IdleTimeoutMonitor.cs
- SessionState.cs
- SchemaObjectWriter.cs
- WebSysDisplayNameAttribute.cs
- NamedPipeTransportBindingElement.cs
- SendingRequestEventArgs.cs
- ExtensionSimplifierMarkupObject.cs
- OleDbPermission.cs
- WebPartActionVerb.cs
- InputMethod.cs
- SourceCollection.cs
- bidPrivateBase.cs
- XmlDocument.cs
- Logging.cs
- InstanceLockedException.cs
- AutoResetEvent.cs
- MessageSecurityProtocolFactory.cs
- CqlParser.cs
- activationcontext.cs
- HybridObjectCache.cs
- ElementsClipboardData.cs
- Error.cs
- AxHost.cs
- FlowDocumentView.cs
- DataTableMappingCollection.cs
- XmlSignificantWhitespace.cs
- FullTrustAssembly.cs
- ListViewHitTestInfo.cs
- IntersectQueryOperator.cs
- InArgument.cs
- HttpErrorTraceRecord.cs
- DES.cs
- SecurityContext.cs
- KeyTimeConverter.cs
- GZipStream.cs
- TableItemStyle.cs
- ToolStripDropDown.cs
- ColumnHeader.cs