public static async Task <Dictionary <string, string> > UpzipDFUPackage(StorageFile zipFile, FirmwareTypeEnum type) { var fileDictionary = await File.UnzipFile(zipFile); string token; DFUServiceManifestRoot manifestObject = null; StorageFile manifest = null; if (fileDictionary.TryGetValue(ManifestFileName, out token)) { manifest = await File.GetStoredFile(token); manifestObject = await GetManifestObject(manifest); switch (type) { case FirmwareTypeEnum.Application: return(GetBinDatFileTokens(fileDictionary, manifestObject.manifest.application.bin_file, manifestObject.manifest.application.dat_file)); case FirmwareTypeEnum.BootLoader: return(GetBinDatFileTokens(fileDictionary, manifestObject.manifest.bootloader.bin_file, manifestObject.manifest.bootloader.dat_file)); case FirmwareTypeEnum.SoftDevice: return(GetBinDatFileTokens(fileDictionary, manifestObject.manifest.softdevice.bin_file, manifestObject.manifest.softdevice.dat_file)); case FirmwareTypeEnum.Softdevice_Bootloader: return(GetBinDatFileTokens(fileDictionary, manifestObject.manifest.softdevice_bootloader.bin_file, manifestObject.manifest.softdevice_bootloader.dat_file)); } } return(null); }
public async static Task <DFUServiceManifestRoot> GetManifestObject(StorageFile manifestText) { StorageFile file = manifestText; DFUServiceManifestRoot manifestObject = null; using (var transaction = await file.OpenStreamForReadAsync()) { using (StreamReader dataReader = new StreamReader(transaction)) { DataContractJsonSerializer js = new DataContractJsonSerializer(typeof(DFUServiceManifestRoot)); manifestObject = (DFUServiceManifestRoot)js.ReadObject(dataReader.BaseStream); } } return(manifestObject); }