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
- DataObjectMethodAttribute.cs
- RawTextInputReport.cs
- smtppermission.cs
- RijndaelManagedTransform.cs
- DynamicMethod.cs
- StorageScalarPropertyMapping.cs
- DataFieldEditor.cs
- ObjectListDesigner.cs
- AutomationTextAttribute.cs
- DataGridViewAdvancedBorderStyle.cs
- UnsafeNativeMethods.cs
- IndexedEnumerable.cs
- XmlAttributeOverrides.cs
- FixedSOMLineCollection.cs
- Matrix3DValueSerializer.cs
- CustomAttribute.cs
- TextEffect.cs
- RubberbandSelector.cs
- Label.cs
- BezierSegment.cs
- DocumentApplicationJournalEntry.cs
- XmlDocumentSchema.cs
- LinqDataSourceUpdateEventArgs.cs
- FlowDocumentView.cs
- WizardPanelChangingEventArgs.cs
- TextFormatter.cs
- ProjectedSlot.cs
- PrintingPermissionAttribute.cs
- UnicodeEncoding.cs
- ModuleConfigurationInfo.cs
- EditorZone.cs
- UserControlAutomationPeer.cs
- SiteMapNode.cs
- MimeBasePart.cs
- CodeDomSerializer.cs
- StaticFileHandler.cs
- PenCursorManager.cs
- PagesSection.cs
- SqlBooleanizer.cs
- Bind.cs
- DurationConverter.cs
- SocketPermission.cs
- TCPClient.cs
- XmlSchemaFacet.cs
- MultiDataTrigger.cs
- Version.cs
- Evidence.cs
- EventListener.cs
- TakeOrSkipWhileQueryOperator.cs
- RemoteWebConfigurationHostServer.cs
- SQLInt16Storage.cs
- DataObjectCopyingEventArgs.cs
- CodeTypeDelegate.cs
- SoapEnvelopeProcessingElement.cs
- TrackingProfileCache.cs
- CacheDependency.cs
- FontSourceCollection.cs
- XhtmlBasicPageAdapter.cs
- assemblycache.cs
- AcceleratedTokenProvider.cs
- SerializationSectionGroup.cs
- DeferredReference.cs
- TextUtf8RawTextWriter.cs
- ChannelDemuxer.cs
- ResourceContainer.cs
- SafeSecurityHandles.cs
- TextSelectionHighlightLayer.cs
- DetailsViewUpdatedEventArgs.cs
- DataSourceComponent.cs
- NativeCppClassAttribute.cs
- recordstate.cs
- ConfigurationUtility.cs
- precedingquery.cs
- SectionInformation.cs
- KerberosTokenFactoryCredential.cs
- LinqDataSourceStatusEventArgs.cs
- TabPanel.cs
- ProfileInfo.cs
- SqlGatherProducedAliases.cs
- RepeatInfo.cs
- OleDbParameterCollection.cs
- RegexCompiler.cs
- CLSCompliantAttribute.cs
- TimeSpanOrInfiniteValidator.cs
- ItemsPresenter.cs
- Registry.cs
- EventLogPermission.cs
- XhtmlTextWriter.cs
- RuntimeWrappedException.cs
- EventLogPermission.cs
- XmlSchemaAttribute.cs
- EncodingDataItem.cs
- Decorator.cs
- HttpValueCollection.cs
- CompilationSection.cs
- DataGridSortCommandEventArgs.cs
- MenuAdapter.cs
- FixUpCollection.cs
- FontDialog.cs
- TreeNodeCollection.cs