gpt4 book ai didi

configuration - Monodroid : Where should I put configuration settings?

转载 作者:行者123 更新时间:2023-12-04 05:32:15 26 4
gpt4 key购买 nike

Miguel de Icaza:

We use a library profile that is better suited for mobile devices, so we removed features that are not necessary (like the entire System.Configuration stack, just like Silverlight does).



在经过.NET多年的开发之后,我习惯于将配置设置存储在 web.configapp.config文件中。
  • 在Android上使用Mono时,应将配置设置放在哪里?
  • 如果很重要,我也想为不同的构建配置存储不同的配置设置。
  • 最佳答案

    我可能会建议使用共享的首选项和编译符号来管理不同的配置。下面是一个示例,说明如何使用首选项文件基于编译符号添加或更改键。此外,您可以创建一个单独的首选项文件,该文件仅适用于特定配置。由于这些 key 并非在所有配置上都可用,因此请确保在使用前始终对其进行检查。

    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();

    关于configuration - Monodroid : Where should I put configuration settings?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14401008/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com