所以我想在应用程序中存储一些设置,我只能读取它们(我认为这几乎就是这个想法).
我如何注入阅读器,我不完全确定如何首先阅读应用程序设置或者它是否已经有一个注入接口.
我想要这样的东西:
public interface IPropertyService
{
string ReadProperty(string key);
}
Run Code Online (Sandbox Code Playgroud)
然后实施:
public class DefaultPropertyService : IPropertyService
{
public string ReadProperty(string key)
{
// what ever code that needs to go here
// to call the application settings reader etc.
return ApplicationSetting[key];
}
}
Run Code Online (Sandbox Code Playgroud)
对这个问题的任何帮助都会很棒
您在哪里存储应用程序设置?Web.Config的appSettings部分不够用吗?
<appSettings>
<add key="someSetting" value="SomeValue"/>
</appSettings>
Run Code Online (Sandbox Code Playgroud)
然后以这种方式阅读你的设置
ConfigurationManager.AppSettings["someSetting"]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12110 次 |
| 最近记录: |