开发者

How to implement wrapper class for AppSettings section, which is in *.config file of another application?

I have few applications in a project. Each app has its own *.config file.

I need to write configuration app to configure all these apps' *.config files simultaneously with comfortable GUI (only appConfig section of each file).

So I need somehow create wrappers (to use it with WPF DataBinding) for every *.config file appSettings section. But I can't figure out how.

I tried to create wrapper class based on AppSettingsBase or ConfigurationSection (AppSettingsSection class is sealed) and it would work if I was trying to work with application's own config file. But when working with external config, you're having access to AppSettingsSection object, instead of NameValueCollection. And I can't cast NameValueCollection to AppSettingsSection, so I can't work with it using wrapper class.

public sealed class Client_exe_AppConfigSectionHandler : ApplicationSettingsBase开发者_开发百科
    {
        public Client_exe_AppConfigSectionHandler()
        {

        }

        [ConfigurationProperty( "ValidBrushColor",
            DefaultValue = "107814",
            IsRequired = true,
IsKey = true )]
        public string validBrushColor
        {
            get
            {
                return ( string )this[ "ValidBrushColor" ];
            }
            set
            {
                this[ "ValidBrushColor" ] = value;
            }
        }
    }

Wrapper class is needed because I need WPF Data Binding.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜