/// <summary>
        /// The update download current bytes.
        /// </summary>
        /// <param name="di">
        /// The di.
        /// </param>
        public static void UpdateDownloadCurrentBytes(DownloadInfo di)
        {
            DownloadInfo info =
                XmlDatastore.GetData <List <DownloadInfo> >().First(x => x.ExpansionFileType == di.ExpansionFileType);

            info.CurrentBytes = di.CurrentBytes;
            UpdateDownload(info);
        }
        /// <summary>
        /// The update metadata.
        /// </summary>
        /// <param name="apkVersion">
        /// The apk version.
        /// </param>
        /// <param name="status">
        /// The download status.
        /// </param>
        public static void UpdateMetadata(int apkVersion, DownloadStatus status)
        {
            var metadata = XmlDatastore.GetData <MetadataTable>();

            metadata.ApkVersion     = apkVersion;
            metadata.DownloadStatus = status;
            XmlDatastore.SaveData(metadata);

            versionCode    = apkVersion;
            downloadStatus = status;
        }
        /// <summary>
        /// Initializes static members of the <see cref="DownloadsDatabase"/> class.
        /// </summary>
        static DownloadsDatabase()
        {
            downloadStatus = DownloadStatus.Unknown;
            flags          = 0;
            versionCode    = -1;

            if (File.Exists(XmlDatastore.GetDataPath <MetadataTable>()))
            {
                downloadStatus = XmlDatastore.GetData <MetadataTable>().DownloadStatus;
                flags          = XmlDatastore.GetData <MetadataTable>().Flags;
                versionCode    = XmlDatastore.GetData <MetadataTable>().ApkVersion;
            }
        }
        /// <summary>
        /// This function will add a new file to the database if it does not exist.
        /// </summary>
        /// <param name="info">
        /// DownloadInfo that we wish to store
        /// </param>
        public static void UpdateDownload(DownloadInfo info)
        {
            var downloads = XmlDatastore.GetData <List <DownloadInfo> >();

            DownloadInfo downloadInfo = downloads.FirstOrDefault(d => d.FileName == info.FileName);

            if (downloadInfo != null)
            {
                downloads.Remove(downloadInfo);
            }

            downloads.Add(info);

            XmlDatastore.SaveData(downloads);
        }
Exemplo n.º 5
0
        public Datastores GetDatastores()
        {
            var dataStores = new Datastores();
            var xmlDatastoreConfiguration = new XmlDatastoreConfiguration(null, null);
            var xmlDatastore = new XmlDatastore(xmlDatastoreConfiguration);

            dataStores.AddDatastore(xmlDatastore);

            var inMemoryDatasToreConfiguration = new InMemoryDatastoreConfiguration();
            var inMemoryDatastore = new InMemoryDatastore();

            dataStores.AddDatastore(inMemoryDatastore);

            dataStores.SelectDatastore(inMemoryDatastore);
            return(dataStores);
        }
Exemplo n.º 6
0
        public Main()
        {
            // const string xmlFileName = @"PassFruit.xml";
            var xmlFilePath = Path.GetTempFileName();

            File.Delete(xmlFilePath);
            var fileExists = File.Exists(xmlFilePath);

            var xmlDatastoreConfiguration = new XmlDatastoreConfiguration(
                () => fileExists ? XDocument.Load(xmlFilePath) : new XDocument(),
                xDocument => xDocument.Save(xmlFilePath)
                );

            _dataStore = new XmlDatastore(xmlDatastoreConfiguration);

            if (!fileExists)
            {
                var fakeDataGenerator = new FakeDataGenerator();
                fakeDataGenerator.GenerateFakeData(_dataStore);
            }
        }
        /// <summary>
        /// The update from database.
        /// </summary>
        /// <param name="info">
        /// The info.
        /// </param>
        public static void UpdateFromDatabase(ref DownloadInfo info)
        {
            DownloadInfo i = info;

            info = XmlDatastore.GetData <List <DownloadInfo> >().First(x => x.FileName == i.FileName);
        }
 /// <summary>
 /// </summary>
 /// <returns>
 /// The System.Collections.Generic.List`1[T -&gt; ExpansionDownloader.Service.DownloadInfo].
 /// </returns>
 public static List <DownloadInfo> GetDownloads()
 {
     return(XmlDatastore.GetData <List <DownloadInfo> >());
 }
 /// <summary>
 /// Returns the download information for the given filename.
 /// </summary>
 /// <param name="fileName">
 /// The file name.
 /// </param>
 /// <returns>
 /// The download information for the filename
 /// </returns>
 public static DownloadInfo GetDownloadInfo(string fileName)
 {
     return(XmlDatastore.GetData <List <DownloadInfo> >().FirstOrDefault(x => x.FileName == fileName));
 }