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
- ValidationSummary.cs
- UserThread.cs
- DatasetMethodGenerator.cs
- ApplicationFileCodeDomTreeGenerator.cs
- ChildChangedEventArgs.cs
- HttpCapabilitiesSectionHandler.cs
- VariantWrapper.cs
- DataGridState.cs
- dtdvalidator.cs
- DecoratedNameAttribute.cs
- PropertyGeneratedEventArgs.cs
- DbConnectionPoolIdentity.cs
- EventMappingSettingsCollection.cs
- DbgUtil.cs
- RuleSettings.cs
- ItemAutomationPeer.cs
- RequestCachePolicy.cs
- TypeSource.cs
- RadioButtonList.cs
- DocumentManager.cs
- ApplicationActivator.cs
- TableParagraph.cs
- ReferenceService.cs
- Logging.cs
- ProfilePropertySettings.cs
- ObjectAnimationUsingKeyFrames.cs
- DeviceFilterDictionary.cs
- MeasureItemEvent.cs
- PrintPreviewDialog.cs
- BezierSegment.cs
- ResourceManager.cs
- dataSvcMapFileLoader.cs
- DescriptionAttribute.cs
- TraceFilter.cs
- CopyAttributesAction.cs
- Directory.cs
- InputLangChangeEvent.cs
- ErrorHandlerFaultInfo.cs
- ConditionCollection.cs
- SiteMapNode.cs
- SelectionChangedEventArgs.cs
- XPathNodeIterator.cs
- NotSupportedException.cs
- ProxyWebPartManager.cs
- StringHandle.cs
- SafeSecurityHandles.cs
- CardSpacePolicyElement.cs
- KeysConverter.cs
- DataPager.cs
- DataControlLinkButton.cs
- ModuleConfigurationInfo.cs
- Color.cs
- RowsCopiedEventArgs.cs
- VirtualizedItemPattern.cs
- InternalDispatchObject.cs
- WindowsListViewItemStartMenu.cs
- ChangeProcessor.cs
- CatalogZoneBase.cs
- Trace.cs
- TransactedBatchContext.cs
- WizardSideBarListControlItem.cs
- AutoGeneratedField.cs
- DesignerTransactionCloseEvent.cs
- DetailsViewCommandEventArgs.cs
- JsonQNameDataContract.cs
- XmlILOptimizerVisitor.cs
- OneWayChannelFactory.cs
- PageBuildProvider.cs
- CheckBoxFlatAdapter.cs
- EarlyBoundInfo.cs
- ObjectDataSourceSelectingEventArgs.cs
- Selection.cs
- RelationshipEndCollection.cs
- SchemaElementDecl.cs
- XNodeNavigator.cs
- HighlightVisual.cs
- BuildProviderUtils.cs
- TextureBrush.cs
- ItemAutomationPeer.cs
- ToolStripSeparatorRenderEventArgs.cs
- PackWebRequest.cs
- XmlAnyElementAttributes.cs
- StateManager.cs
- OperatingSystem.cs
- DisableDpiAwarenessAttribute.cs
- DivideByZeroException.cs
- RowSpanVector.cs
- XmlHierarchicalDataSourceView.cs
- BezierSegment.cs
- TypedTableHandler.cs
- PolygonHotSpot.cs
- XmlText.cs
- PostBackOptions.cs
- DependencyPropertyValueSerializer.cs
- EdmTypeAttribute.cs
- TypeToStringValueConverter.cs
- ApplicationSecurityManager.cs
- BStrWrapper.cs
- PersonalizableTypeEntry.cs
- TableLayoutStyle.cs