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
- ColorConvertedBitmap.cs
- Missing.cs
- ByteArrayHelperWithString.cs
- ImmComposition.cs
- ReadOnlyDataSourceView.cs
- MediaElementAutomationPeer.cs
- DbConnectionPoolGroupProviderInfo.cs
- CancelEventArgs.cs
- DataFormats.cs
- DbMetaDataColumnNames.cs
- SrgsDocument.cs
- FlatButtonAppearance.cs
- arc.cs
- XPathPatternParser.cs
- ParameterToken.cs
- COM2ColorConverter.cs
- ConditionalAttribute.cs
- LineBreakRecord.cs
- SQlBooleanStorage.cs
- ResourceReferenceKeyNotFoundException.cs
- AsyncMethodInvoker.cs
- SoapAttributes.cs
- Splitter.cs
- InstanceKeyCollisionException.cs
- SelectionItemPattern.cs
- ImageDesigner.cs
- BuilderInfo.cs
- DBProviderConfigurationHandler.cs
- CodeMemberField.cs
- TraceListeners.cs
- TextEffectCollection.cs
- ExpressionNode.cs
- CallbackValidatorAttribute.cs
- TagPrefixInfo.cs
- ManipulationLogic.cs
- SqlDataSourceView.cs
- DetailsViewRowCollection.cs
- CopyNamespacesAction.cs
- DataGridViewAccessibleObject.cs
- LinqDataSourceInsertEventArgs.cs
- StateItem.cs
- WebPartMovingEventArgs.cs
- FixedHyperLink.cs
- ProfileSettingsCollection.cs
- DataGridDetailsPresenterAutomationPeer.cs
- BrowserDefinitionCollection.cs
- BaseValidatorDesigner.cs
- ComponentCollection.cs
- Light.cs
- Transactions.cs
- StorageScalarPropertyMapping.cs
- Queue.cs
- TargetControlTypeCache.cs
- AdapterUtil.cs
- ErrorStyle.cs
- ToolStripRenderer.cs
- TrustManager.cs
- AppearanceEditorPart.cs
- ModelItemCollectionImpl.cs
- HtmlAnchor.cs
- EventInfo.cs
- IfAction.cs
- ValueType.cs
- DependentList.cs
- PlaceHolder.cs
- GridViewDesigner.cs
- SamlAssertion.cs
- KeyNotFoundException.cs
- ColumnHeaderConverter.cs
- MenuItemCollectionEditorDialog.cs
- DictionaryMarkupSerializer.cs
- PrivateFontCollection.cs
- CodeComment.cs
- ExtractorMetadata.cs
- Int16Storage.cs
- MimeMapping.cs
- DeleteIndexBinder.cs
- HwndProxyElementProvider.cs
- EncoderNLS.cs
- Errors.cs
- StoreAnnotationsMap.cs
- ItemCollection.cs
- ToolStripRendererSwitcher.cs
- SpStreamWrapper.cs
- TemplateManager.cs
- TimelineGroup.cs
- CodeArgumentReferenceExpression.cs
- Shape.cs
- GraphicsState.cs
- ConnectionInterfaceCollection.cs
- Tuple.cs
- Speller.cs
- DataServiceProviderMethods.cs
- PropertyPushdownHelper.cs
- FunctionImportMapping.cs
- HtmlInputFile.cs
- BitmapMetadataEnumerator.cs
- OleDbFactory.cs
- BigInt.cs
- XmlWriterTraceListener.cs