Jim*_* G. 8 configuration xamarin.android xamarin.mobile
我们使用更适合移动设备的库配置文件,因此我们删除了不必要的功能(如整个System.Configuration堆栈,就像Silverlight一样).
经过多年的.NET开发的,我习惯了在存储配置设置web.config和app.config文件.
Mik*_*nis 12
我可能会建议使用共享首选项和编译符号来管理不同的配置.下面是如何使用首选项文件根据编译符号添加或更改键的示例.此外,您可以创建仅适用于特定配置的单独首选项文件.由于这些密钥在所有配置中都不可用,因此请确保在使用之前始终对它们执行检查.
var prefs = this.GetSharedPreferences("Config File Name", FileCreationMode.Private);
var editor = prefs.Edit();
#if MonoRelease
editor.PutString("MyKey", "My Release Value");
editor.PutString("ReleaseKey", "My Release Value");
#else
editor.PutString("MyKey", "My Debug Value");
editor.PutString("DebugKey", "My Debug Value");
#endif
editor.PutString("CommonKey", "Common Value");
editor.Commit();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5634 次 |
| 最近记录: |