Xamarin.forms Prism库中的应用程序类是否持久存储数据?
我目前正在使用Prism库构建一个Xamarin.Forms应用程序。Prism为开发人员提供了一个接口“IApplicationStore”,用于公开属性。我在我的应用程序中实现接口。我想知道界面中公开的属性字典是否会将数据持久地存储到用户的设备上,或者该数据是否仅在应用程序打开时或在后台可用?Prism Library Github页面上的文档并没有具体说明这一点。以下是Github上Prism repo上应用程序存储的源代码:Xamarin.forms Prism库中的应用程序类是否持久存储数据?,xamarin.forms,Xamarin.forms,我目前正在使用Prism库构建一个Xamarin.Forms应用程序。Prism为开发人员提供了一个接口“IApplicationStore”,用于公开属性。我在我的应用程序中实现接口。我想知道界面中公开的属性字典是否会将数据持久地存储到用户的设备上,或者该数据是否仅在应用程序打开时或在后台可用?Prism Library Github页面上的文档并没有具体说明这一点。以下是Github上Prism repo上应用程序存储的源代码: using System.Collections.Generi
using System.Collections.Generic;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace Prism.AppModel
{
public class ApplicationStore : IApplicationStore
{
public IDictionary<string, object> Properties
{
get { return Application.Current.Properties; }
}
public Task SavePropertiesAsync() =>
Application.Current.SavePropertiesAsync();
}
}
使用System.Collections.Generic;
使用System.Threading.Tasks;
使用Xamarin.Forms;
命名空间Prism.AppModel
{
公共类应用程序存储:IApplicationStore
{
公共索引属性
{
获取{return Application.Current.Properties;}
}
公共任务SavePropertiesAsync()=>
Application.Current.SavePropertiesAsync();
}
}
所以它只是围绕Xamarin.Forms应用程序属性的包装。
如果要持久化这些属性,只需调用SavePropertiesAsync()即可:
感谢您的澄清。“这就清楚了。”耶鲁米雅,你能把这个问题记下来吗?谢谢