Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / 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; } } }/// 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
- RequestReplyCorrelator.cs
- HandlerBase.cs
- AsyncContentLoadedEventArgs.cs
- Baml6ConstructorInfo.cs
- SerializerDescriptor.cs
- DbDataAdapter.cs
- ProviderException.cs
- ThousandthOfEmRealPoints.cs
- TextEditorSelection.cs
- DocumentSequence.cs
- StringPropertyBuilder.cs
- SecurityUtils.cs
- HyperLinkColumn.cs
- DispatchOperationRuntime.cs
- ListMarkerLine.cs
- GroupItem.cs
- FilePrompt.cs
- X509UI.cs
- ProcessThreadCollection.cs
- Substitution.cs
- BrowserDefinitionCollection.cs
- Compilation.cs
- TextHidden.cs
- PrimitiveXmlSerializers.cs
- IItemContainerGenerator.cs
- InlineCollection.cs
- RawStylusInput.cs
- SQLGuidStorage.cs
- UserPersonalizationStateInfo.cs
- LineServicesCallbacks.cs
- HierarchicalDataTemplate.cs
- SignedXml.cs
- XmlImplementation.cs
- HierarchicalDataBoundControlAdapter.cs
- DebugInfo.cs
- WebHttpBinding.cs
- GlyphCache.cs
- X509SubjectKeyIdentifierClause.cs
- DataColumnCollection.cs
- TypeAccessException.cs
- DataGridViewRowHeightInfoNeededEventArgs.cs
- xmlfixedPageInfo.cs
- XmlIlTypeHelper.cs
- WmlLabelAdapter.cs
- ProcessModuleCollection.cs
- _UriSyntax.cs
- ColumnWidthChangingEvent.cs
- DebugView.cs
- WorkItem.cs
- MaxMessageSizeStream.cs
- TriState.cs
- ClipboardProcessor.cs
- EventHandlerList.cs
- AssemblyCacheEntry.cs
- PropertyHelper.cs
- ToolboxCategory.cs
- XmlSerializerNamespaces.cs
- ConfigDefinitionUpdates.cs
- StorageComplexPropertyMapping.cs
- FixedElement.cs
- ReaderOutput.cs
- ConditionCollection.cs
- BrowserCapabilitiesCodeGenerator.cs
- RemotingConfigParser.cs
- SafeArrayTypeMismatchException.cs
- CriticalExceptions.cs
- BitmapPalettes.cs
- FilePrompt.cs
- ConstructorNeedsTagAttribute.cs
- FormatVersion.cs
- BuildProviderCollection.cs
- DependencyPropertyAttribute.cs
- localization.cs
- StrokeCollection2.cs
- RequestCachingSection.cs
- ButtonDesigner.cs
- GifBitmapDecoder.cs
- TabControl.cs
- XamlToRtfWriter.cs
- WindowsTooltip.cs
- HandlerBase.cs
- DeploymentSection.cs
- SapiRecoContext.cs
- CapabilitiesPattern.cs
- PropertyTabChangedEvent.cs
- Operator.cs
- compensatingcollection.cs
- TemplateControlBuildProvider.cs
- RSAPKCS1SignatureFormatter.cs
- PenThreadWorker.cs
- HtmlShim.cs
- FontResourceCache.cs
- SynchronizationContext.cs
- CompressEmulationStream.cs
- PersonalizationProviderHelper.cs
- CLSCompliantAttribute.cs
- SmtpException.cs
- MouseGesture.cs
- DataGridViewImageCell.cs
- TypedDatasetGenerator.cs