private T DeSerializeAndDecompressObjectFromEncryptedFile <T>(string path, IProgress <StorageManagerProgress> progress)
        {
            EncryptionManager encryptionManager = new EncryptionManager();
            Stream            input             = null;
            MemoryStream      output            = new MemoryStream();

            try
            {
                input          = encryptionManager.DecryptFileToMemoryStream(path, _settings.GetPassword(), new CryptoProgress(progress));
                input.Position = 0;

                if (_settings.UseMultithreading && CompressionFileHeader.VerifyFileHeader(input))
                {
                    DeflateDataMultithreded(input, output, progress);
                }
                else
                {
                    CodeProgressImplementation coderProgress = new CodeProgressImplementation(progress, CodeProgressImplementation.CodingOperations.Decoding);
                    progress?.Report(new StorageManagerProgress {
                        ProgressPercentage = 0, Text = "Starting LZMA multithreaded decoding of file"
                    });
                    DeflateData(input, output, input.Length, coderProgress).RunSynchronously();
                }

                output.Flush();
                output.Position = 0;
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Error in StorageManager.DeSerializeAndDecompressObjectFromEncryptedFile()");
            }
            finally
            {
                input?.Close();
            }

            Attribute[] attrs = Attribute.GetCustomAttributes(typeof(T));
            bool        protoBufferCompatible = attrs.OfType <DataContractAttribute>().Any();

            progress?.Report(protoBufferCompatible ? new StorageManagerProgress {
                ProgressPercentage = 0, Text = "Deserializing using Protobuffer"
            } : new StorageManagerProgress {
                ProgressPercentage = 0, Text = "Deserializing using BinaryFormatter"
            });

            if (protoBufferCompatible)
            {
                return(Serializer.Deserialize <T>(output));
            }

            BinaryFormatter binaryFormatter = new BinaryFormatter();

            return((T)binaryFormatter.Deserialize(output));
        }