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
- EntityWrapperFactory.cs
- ColumnWidthChangingEvent.cs
- XmlUTF8TextReader.cs
- KnownTypesProvider.cs
- QueryStringHandler.cs
- dbdatarecord.cs
- XhtmlBasicListAdapter.cs
- AccessedThroughPropertyAttribute.cs
- VBIdentifierName.cs
- DataStreamFromComStream.cs
- XomlSerializationHelpers.cs
- PathGeometry.cs
- SecurityTokenResolver.cs
- IPEndPoint.cs
- Function.cs
- WebPartConnectionsConfigureVerb.cs
- HashMembershipCondition.cs
- DataBindingList.cs
- ADConnectionHelper.cs
- XmlTypeAttribute.cs
- CachedBitmap.cs
- ListControlBuilder.cs
- ADMembershipProvider.cs
- ArrayWithOffset.cs
- DataControlButton.cs
- TdsParserStaticMethods.cs
- MarginCollapsingState.cs
- Thread.cs
- DataGridViewCellStyleBuilderDialog.cs
- SqlNamer.cs
- JoinSymbol.cs
- FixedSOMGroup.cs
- SecurityPolicySection.cs
- GenericUriParser.cs
- Header.cs
- UpdateExpressionVisitor.cs
- AspCompat.cs
- QueryHandler.cs
- BrushValueSerializer.cs
- ToolStripItemRenderEventArgs.cs
- SystemIPGlobalStatistics.cs
- HttpValueCollection.cs
- MemoryStream.cs
- XmlSchemaSimpleContent.cs
- RegexReplacement.cs
- SessionState.cs
- XmlBindingWorker.cs
- AttachmentService.cs
- SqlInternalConnection.cs
- SourceFileBuildProvider.cs
- PasswordDeriveBytes.cs
- BamlCollectionHolder.cs
- XmlSchemaAnnotated.cs
- CryptoConfig.cs
- DbgUtil.cs
- UrlMapping.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- ResourceDictionary.cs
- HyperLinkStyle.cs
- PauseStoryboard.cs
- CollectionViewSource.cs
- SymmetricCryptoHandle.cs
- ConfigXmlComment.cs
- AllMembershipCondition.cs
- SqlCacheDependencyDatabaseCollection.cs
- DocobjHost.cs
- InternalTypeHelper.cs
- LabelDesigner.cs
- AttributeQuery.cs
- PermissionListSet.cs
- GeneralTransformGroup.cs
- DataServiceRequestException.cs
- Processor.cs
- ThreadStartException.cs
- WCFServiceClientProxyGenerator.cs
- ParameterModifier.cs
- RawStylusInputCustomDataList.cs
- TextBox.cs
- ToolBarDesigner.cs
- InputLangChangeRequestEvent.cs
- DesignTimeVisibleAttribute.cs
- ScriptServiceAttribute.cs
- GridViewSortEventArgs.cs
- SynchronizingStream.cs
- ReflectEventDescriptor.cs
- XmlSchemaProviderAttribute.cs
- Point4D.cs
- SchemaComplexType.cs
- XmlSequenceWriter.cs
- WarningException.cs
- RecordsAffectedEventArgs.cs
- ThreadStartException.cs
- RuleInfoComparer.cs
- StylusDownEventArgs.cs
- BitConverter.cs
- DataTemplateKey.cs
- COM2PictureConverter.cs
- TextDecorations.cs
- WebReferenceCollection.cs
- DragSelectionMessageFilter.cs