mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-11-02 00:16:07 +00:00
NativeAPI UWP
This commit is contained in:
parent
87c5a6bad9
commit
54fcc0bc37
2 changed files with 27 additions and 7 deletions
|
|
@ -1,14 +1,20 @@
|
|||
using AideDeJeu.Tools;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using Windows.ApplicationModel;
|
||||
|
||||
[assembly: Xamarin.Forms.Dependency(typeof(AideDeJeu.Droid.Version_Android))]
|
||||
namespace AideDeJeu.Droid
|
||||
[assembly: Xamarin.Forms.Dependency(typeof(AideDeJeu.UWP.Version_UWP))]
|
||||
namespace AideDeJeu.UWP
|
||||
{
|
||||
public class Version_Android : INativeAPI
|
||||
public class Version_UWP : INativeAPI
|
||||
{
|
||||
public string GetVersion()
|
||||
{
|
||||
return "";
|
||||
Package package = Package.Current;
|
||||
PackageId packageId = package.Id;
|
||||
PackageVersion version = packageId.Version;
|
||||
|
||||
return string.Format("{0}.{1}", version.Major, version.Minor);
|
||||
}
|
||||
|
||||
public int GetBuild()
|
||||
|
|
@ -18,7 +24,21 @@ namespace AideDeJeu.Droid
|
|||
|
||||
public string GetDatabasePath(string databaseName)
|
||||
{
|
||||
return Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, databaseName);
|
||||
var documentsDirectoryPath = Windows.Storage.ApplicationData.Current.LocalFolder.Path;
|
||||
var path = Path.Combine(documentsDirectoryPath, databaseName);
|
||||
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
var assembly = typeof(Version_UWP).GetTypeInfo().Assembly;
|
||||
using (var inStream = assembly.GetManifestResourceStream("AideDeJeu.UWP.Assets." + databaseName))
|
||||
{
|
||||
using (var outStream = new FileStream(path, FileMode.Create))
|
||||
{
|
||||
inStream.CopyTo(outStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
return path;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue