Болтун
Зарегистрирован: 04 July 2005
Сообщения: 276
Примеры кода: 0
|
Re: Чтение любого XML из кастом-секции app.config |
19 January 2007 10:56 |
|
|
|
|
Здравствуйте, Ёрик, Вы писали:
Ё>Требуется прочитать кастом-секцию из app.config. Наряду со строго специфицированными тегами требуется прочитать секцию произвольного типа, содержащую любой валидный XML, например:
Ё>Можно ли это сделать на атрибутах типа ConfigurationProperty? Очень не хочется парсить app.config вручную, учитывая то, что остальные теги прекрасно ложатся на атрибуты.
может быть, вот это подойдет
ConfigurationManager
Note: This method is new in the .NET Framework version 2.0.
Retrieves a specified configuration section for the current application's default configuration.
Namespace: System.Configuration
Assembly: System.Configuration (in system.configuration.dll)
Syntax
Visual Basic (Declaration)
Public Shared Function GetSection ( _
sectionName As String _
) As Object
Visual Basic (Usage)
Dim sectionName As String
Dim returnValue As Object
returnValue = ConfigurationManager.GetSection(sectionName)
C#
public static Object GetSection (
string sectionName
)
Parameters
sectionName
The configuration section path and name.
Return Value
The specified ConfigurationSection object, or a null reference (Nothing in Visual Basic) if the section does not exist
ConfigurationSection
Note: This class is new in the .NET Framework version 2.0.
Represents a section within a configuration file.
Namespace: System.Configuration
Assembly: System.Configuration (in system.configuration.dll)
Syntax
Visual Basic (Declaration)
Public MustInherit Class ConfigurationSection
Inherits ConfigurationElement
Visual Basic (Usage)
Dim instance As ConfigurationSection
C#
public abstract class ConfigurationSection : ConfigurationElement
C++
public ref class ConfigurationSection abstract : public ConfigurationElement
J#
public abstract class ConfigurationSection extends ConfigurationElement
JScript
public abstract class ConfigurationSection extends ConfigurationElement
Remarks
You use the ConfigurationSection to implement a custom section type. Extend the ConfigurationSection class to provide custom handling and programmatic access to custom configuration sections.
A section registers its handling type with an entry in the configSections.
Refer to the configuration file excerpt shown in the example next.
Данное сообщение получено с сайта RSDN
|
|