Code:
/ DotNET / DotNET / 8.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
- URLIdentityPermission.cs
- RtType.cs
- WaitHandle.cs
- JavaScriptString.cs
- Group.cs
- VsPropertyGrid.cs
- DataGridPagerStyle.cs
- ToolStripDropTargetManager.cs
- Pair.cs
- XmlDataSourceView.cs
- Query.cs
- DataStreams.cs
- EditingMode.cs
- TextContainerChangeEventArgs.cs
- ArgumentOutOfRangeException.cs
- TextServicesDisplayAttribute.cs
- Accessors.cs
- MenuAdapter.cs
- _FtpDataStream.cs
- ToolTip.cs
- XmlSchemaSimpleType.cs
- AlternateView.cs
- FreezableCollection.cs
- ContextMenuStrip.cs
- SystemException.cs
- SymbolMethod.cs
- CryptoApi.cs
- DataRelationCollection.cs
- RepeaterCommandEventArgs.cs
- DiagnosticTrace.cs
- XmlChoiceIdentifierAttribute.cs
- ServiceModelConfigurationSectionCollection.cs
- Panel.cs
- BitmapFrameDecode.cs
- JavaScriptSerializer.cs
- XmlSchemaElement.cs
- LinqDataSourceView.cs
- InfoCardXmlSerializer.cs
- WindowsSolidBrush.cs
- DesignSurfaceServiceContainer.cs
- AccessDataSourceView.cs
- WebPartConnectionsCancelEventArgs.cs
- DeclarativeCatalogPart.cs
- DesignerForm.cs
- Directory.cs
- JsonWriterDelegator.cs
- TextElement.cs
- HttpCachePolicy.cs
- MetricEntry.cs
- InputElement.cs
- QuotedPairReader.cs
- ListViewVirtualItemsSelectionRangeChangedEvent.cs
- Utils.cs
- ReaderWriterLock.cs
- XmlValidatingReader.cs
- CallbackValidator.cs
- TypeToArgumentTypeConverter.cs
- StylusButton.cs
- CodeGenerator.cs
- ThrowHelper.cs
- RuleSettings.cs
- ZipIOEndOfCentralDirectoryBlock.cs
- GenerateHelper.cs
- AssemblyAttributes.cs
- ResourceDescriptionAttribute.cs
- CommandID.cs
- Camera.cs
- RangeValidator.cs
- TileBrush.cs
- IIS7WorkerRequest.cs
- DocumentReferenceCollection.cs
- MetadataCache.cs
- FileSecurity.cs
- HwndProxyElementProvider.cs
- DataBindingCollection.cs
- ChtmlCommandAdapter.cs
- ListViewItem.cs
- ThumbAutomationPeer.cs
- MatrixTransform.cs
- SecurityRuntime.cs
- FileStream.cs
- CapabilitiesRule.cs
- NameSpaceExtractor.cs
- BuildResult.cs
- AppDomainManager.cs
- UIAgentMonitorHandle.cs
- PointLight.cs
- JulianCalendar.cs
- MembershipSection.cs
- RemotingConfigParser.cs
- StringPropertyBuilder.cs
- GeneralTransformGroup.cs
- TypeDelegator.cs
- GradientStop.cs
- DataViewListener.cs
- HitTestFilterBehavior.cs
- LinqDataSource.cs
- RemotingConfigParser.cs
- DropSourceBehavior.cs
- QuadraticBezierSegment.cs