默认情况下,每个平台都会在适合该平台的文件夹位置创建一个数据库 - 例如触摸用途:
public ISQLiteConnection Create(string address)
{
var path = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
return new SQLiteConnection(Path.Combine(path, address));
}
from https://github.com/slodge/MvvmCross/blob/v3/Plugins/Cirrious/Sqlite/Cirrious.MvvmCross.Plugins.Sqlite.Touch/MvxTouchSQLiteConnectionFactory.cs#L18 https://github.com/slodge/MvvmCross/blob/v3/Plugins/Cirrious/Sqlite/Cirrious.MvvmCross.Plugins.Sqlite.Touch/MvxTouchSQLiteConnectionFactory.cs#L18
为了读/写文件,MvvmCross 确实捆绑了一个文件插件 - 默认情况下它也在平台特定位置运行 - 但两者可能不完美匹配 - 例如看:
protected override string FullPath(string path)
{
if (path.StartsWith(ResScheme))
return path.Substring(ResScheme.Length);
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), path);
}
from https://github.com/slodge/MvvmCross/blob/v3/Plugins/Cirrious/File/Cirrious.MvvmCross.Plugins.File.Touch/MvxTouchFileStore.cs#L22 https://github.com/slodge/MvvmCross/blob/v3/Plugins/Cirrious/File/Cirrious.MvvmCross.Plugins.File.Touch/MvxTouchFileStore.cs#L22
由于这种不匹配,为了跨平台共享相同的特定于数据库的复制代码,您可能会发现在每个平台上注入您自己的特定于平台的副本更容易 - 有关注入特定于平台的服务的更多信息,请参阅http://slodge.blogspot.co.uk/2013/06/n31-injection-platform-specific.html http://slodge.blogspot.co.uk/2013/06/n31-injection-platform-specific.html