xamarin.forms - Prism 库中的 Application 类是否持久存储数据?
问题描述
我目前正在使用 Prism 库来构建 Xamarin.Forms 应用程序。Prism 为开发人员提供了一个公开属性的接口“IApplicationStore”。我在我的应用程序中实现了接口。我想知道接口中公开的属性字典是否将数据持久存储到用户的设备,或者这些数据仅在应用程序打开或在后台可用时可用?Prism Library Github 页面上的文档并没有真正指定这一点。
解决方案
这是 Github 上 Prism repo 上 ApplicationStore 的源代码:
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();
}
}
所以它只是 Xamarin.Forms 应用程序属性的包装器。如果要保留属性,只需调用 SavePropertiesAsync() 就可以了:
推荐阅读
- tomcat - 页面未显示,因为启动应用程序时 IE 上的请求实体太大
- json - 如何在表中显示从 ReactJS 后端动态获取的对象数组
- javascript - 如何将错误带回正常的事件流?
- java - 如何更快地在 MongoDB 中获得等效的此功能?WHERE 子句?
- spring-boot - KeyCloak 服务器引起:java.lang.ClassNotFoundException:java.security.acl.Group
- python - AttributeError:类型对象“DatasetV2”没有属性“parallel_interleave”
- jquery - 延迟加载图片(webp + 后备)
- python-3.x - 我们可以在 python 中使用数据框直接连接 teradata sql 查询吗?
- reactjs - 使用渲染方法而不是直接返回
- sql - oracle数据库中未提交读取的替代方案