public ContainerizeFileTask(string filePath, ContainerizationSettingsModel settingsModel) : base(ResourceType.File, filePath)
        {
            InnerTask = new Task(() =>
            {
                if (Path.GetExtension(filePath).Equals(settingsModel.Extension))
                {
                    return;
                }

                ContainerHelper.ContainerizeFile(filePath, AesHelper.GetNewAesKey(), settingsModel.Password);
                var newPath = FileGeneratorHelper.GetValidFileNameForDirectory(
                    DirectoryHelper.GetDirectoryPath(filePath),
                    Path.GetFileNameWithoutExtension(filePath),
                    settingsModel.Extension);

                File.Move(filePath, newPath);

                Result.Value = new FileModel
                {
                    File    = Path.GetFileName(filePath),
                    Time    = DateTime.Now,
                    Secured = newPath
                };
            });
        }
        public OpenAesPasswordStoreTask(string filePath, string password) : base(ResourceType.File, filePath)
        {
            InnerTask = new Task(() =>
            {
                if (!File.Exists(filePath))
                {
                    ContainerizeNewAesPasswordStore(filePath);
                }

                if (ContainerHelper.ValidateContainer(filePath, password))
                {
                    ContainerHelper.DecontainerizeFile(filePath, password);
                    using (var fs = new FileStream(filePath, FileMode.Open))
                    {
                        if (fs.Length > 0 && new BinaryFormatter().Deserialize(fs) is List <PasswordModel> models)
                        {
                            Result.Value = new OpenAesPasswordStoreTaskResultModel(models);
                        }
                        else
                        {
                            ContainerizeNewAesPasswordStore(filePath);
                        }
                    }

                    ContainerHelper.ContainerizeFile(filePath, AesHelper.GetNewAesKey(), password);
                }
                else
                {
                    ContainerizeNewAesPasswordStore(filePath);
                }

                void ContainerizeNewAesPasswordStore(string path)
                {
                    using (var fs = new FileStream(path, FileMode.Create))
                    {
                        new BinaryFormatter().Serialize(fs, new List <PasswordModel>());
                    }
                    ContainerHelper.ContainerizeFile(path, AesHelper.GetNewAesKey(), password);
                    Result.Value = new OpenAesPasswordStoreTaskResultModel(new List <PasswordModel>());
                    return;
                }
            });
        }
        public AesSavePasswordsTask(string filePath, string password, List <PasswordModel> models) : base(ResourceType.File, filePath)
        {
            InnerTask = new Task(() =>
            {
                if (ContainerHelper.ValidateContainer(filePath, password))
                {
                    ContainerHelper.DecontainerizeFile(filePath, password);
                    using (var fs = new FileStream(filePath, FileMode.Open))
                    {
                        if (new BinaryFormatter().Deserialize(fs) is List <PasswordModel> existingModels)
                        {
                            models.AddRange(existingModels);
                        }
                    }
                }

                using (var fs = new FileStream(filePath, FileMode.Create))
                {
                    new BinaryFormatter().Serialize(fs, models);
                }

                ContainerHelper.ContainerizeFile(filePath, AesHelper.GetNewAesKey(), password);
            });
        }