/// <summary> /// Decrypt the connection settings. /// </summary> public static ConnectionSettings Decrypt ( [NotNull] string text ) { Sure.NotNull(text, nameof(text)); byte[] bytes = Convert.FromBase64String(text); bytes = CompressionUtility.Decompress(bytes); ConnectionSettings result = bytes.RestoreObjectFromMemory <ConnectionSettings>(); return(result); }
public string Decompress() { byte[] decompressed; switch (CompressionType) { case CompressionType.Gzip: decompressed = CompressionUtility.Decompress(Bytes); break; case CompressionType.None: decompressed = Bytes; break; default: throw new NotImplementedException(); } return(Encoding.UTF8.GetString(decompressed)); }
private void GetFilesToKeep(string sdk) { var myFiles = new List <string>(); string compressedArchivePath = Path.Combine(mSdksFolder, sdk, "nuGetPackagesArchive.lzma"); Console.WriteLine("Decompressing " + compressedArchivePath); using (var archiveStream = CreateTemporaryFileStream()) { // decompress the LZMA stream using (var lzmaStream = File.OpenRead(compressedArchivePath)) { var progress = new MyProgress(); CompressionUtility.Decompress(lzmaStream, archiveStream, progress); } // reset the uncompressed stream archiveStream.Seek(0, SeekOrigin.Begin); Console.WriteLine("Rooting files in " + compressedArchivePath); // read as a zip archive using (var archive = new ZipArchive(archiveStream, ZipArchiveMode.Read)) { var indexEntry = archive.GetEntry(IndexFileName); using (var indexReader = new StreamReader(indexEntry.Open())) { for (var line = indexReader.ReadLine(); line != null; line = indexReader.ReadLine()) { var lineParts = line.Split(pipeSeperator); if (lineParts.Length != 2) { throw new Exception("Unexpected index line format, too many '|'s."); } string target = lineParts[0]; string source = lineParts[1]; var zipSeperatorIndex = target.IndexOf("::", StringComparison.OrdinalIgnoreCase); string destinationPath; if (zipSeperatorIndex != -1) { string zipRelativePath = target.Substring(0, zipSeperatorIndex); destinationPath = Path.Combine(mFallbackFolder, zipRelativePath); } else { destinationPath = Path.Combine(mFallbackFolder, target); } //Normalize path (forward slash to backslash) myFiles.Add(Path.GetFullPath(destinationPath)); } } } } lock (mFilesToKeep) { foreach (var f in myFiles) { mFilesToKeep.Add(f); } } }