Ejemplo n.º 1
0
        private static IDictionary <string, Task <DirectoryInfo> > StartCopyingAndUnpackingBinFiles(IEnumerable <FileInfo> sourceBinFiles, DirectoryInfo gameFileCopyDirectory)
        {
            var tasks = new Dictionary <string, Task <DirectoryInfo> >();

            foreach (var sourceFile in sourceBinFiles)
            {
                DirectoryInfo unpack()
                {
                    _logger.LogInfo($"Unpacking \"{sourceFile.Name}\"...");

                    var defaultTempLocation = Settings.TempLocation;

                    Settings.TempLocation = gameFileCopyDirectory.FullName;

                    var outputPath = _unpacker.Unpack(sourceFile);

                    Settings.TempLocation = defaultTempLocation;

                    _logger.LogInfo($"\"{sourceFile.Name}\" unpacked.");

                    return(new DirectoryInfo(outputPath));
                }

                var unpackTask = _taskFactory.StartNew(unpack);

                tasks.Add($"{sourceFile.Name}", unpackTask);
            }
            return(tasks);
        }
Ejemplo n.º 2
0
        private IEnumerable <FileInfo> GetBlkxFiles(string sourceFileName)
        {
            var sourceFile      = _fileManager.GetFileInfo(Settings.WarThunderLocation, sourceFileName);
            var outputDirectory = new DirectoryInfo(_unpacker.Unpack(sourceFile));

            _unpacker.Unpack(outputDirectory, ETool.BlkUnpacker);

            return(outputDirectory.GetFiles($"{ECharacter.Asterisk}{ECharacter.Period}{EFileExtension.Blkx}", SearchOption.AllDirectories));
        }
        public void Unpack_Bin_OutputFolderShouldContainFiles()
        {
            // arrange
            var sourceFile = _fileManager.GetFileInfo(Settings.WarThunderLocation, EFile.WarThunder.StatAndBalanceParameters);

            // act
            var outputDirectory = new DirectoryInfo(_unpacker.Unpack(sourceFile));

            // assert
            outputDirectory.GetFiles().Should().NotBeEmpty();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Распаковка скрываемого текста из стегоконтейнера.
        /// </summary>
        public void Unpack()
        {
            var stegocontainer = _helperIO.ReadImage(
                PathStegoContainer);
            var unhidingText = _unpacker.Unpack(
                stegocontainer);

            _helperIO.WriteText(PathUnhidingText,
                                unhidingText);
        }
Ejemplo n.º 5
0
 public static bool TryUnpack(this IUnpacker unpacker, out Playlist playlist, Stream playlistStream)
 {
     try
     {
         return((playlist = unpacker.Unpack(playlistStream)) != null);
     }
     catch (Exception)
     {
         playlist = null;
         return(false);
     }
 }
Ejemplo n.º 6
0
 private async Task <bool> UnpackFile(IUnpacker unpacker, string archiveFile, string targetDir)
 {
     unpacker.ProgressChanged += (object sender, UnpackingProgressArgs e) =>
     {
         Dispatcher.CurrentDispatcher.Invoke(() =>
         {
             unpackProgress.Maximum = e.TotalFiles;
             unpackProgress.Value   = e.CurrentFile;
             unpackText.Text        = $"Unpacking {e.CurrentFilename}";
         });
     };
     Directory.CreateDirectory(targetDir);
     return(await unpacker.Unpack(archiveFile, targetDir));
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Unpack an object from JSON format.
        /// </summary>
        /// <param name="json"></param>
        /// <returns></returns>
        public static IPackable Unpack(string json)
        {
            IDictionary <string, object> values = UnpackRaw(json);

            if (values == null)
            {
                return(null);
            }
            // Do we have a type key ?
            Type t = null;

            if (values.ContainsKey(TypeKey))
            {
                try
                {
                    t = Type.GetType(values[TypeKey].ToString());
                }
                catch (Exception ex)
                {
                }
            }
            if (t == null)
            {
                // Create a generic object instance
                t = typeof(GenericPackedObject);
            }
            // Get the unpacker for this type
            Type unpackerType = typeof(IUnpacker <>).MakeGenericType(new Type[] { t });
            IUnpacker <IPackable> unpacker = (IUnpacker <IPackable>)Locator.Current.GetService(unpackerType);

            if (unpacker == null)
            {
                return(null);
            }
            try
            {
                return(unpacker.Unpack(values));
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Unpack a specific type of object from JSON
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="json"></param>
        /// <returns></returns>
        public static T Unpack <T>(string json) where T : IPackable
        {
            IDictionary <string, object> values = UnpackRaw(json);

            if (values == null)
            {
                return(default(T));
            }
            IUnpacker <T> unpacker = Locator.Current.GetService <IUnpacker <T> >();

            if (unpacker == null)
            {
                return(default(T));
            }
            try
            {
                return(unpacker.Unpack(values));
            }
            catch (Exception ex)
            {
                return(default(T));
            }
        }