public static DuplexPipePair CreateConnectionPair(PipeOptions inputOptions, PipeOptions outputOptions) { var input = new StreamPipeline(inputOptions); var output = new StreamPipeline(outputOptions); var transportToApplication = new DuplexPipe(output.Reader, input.Writer); var applicationToTransport = new DuplexPipe(input.Reader, output.Writer); return(new DuplexPipePair(applicationToTransport, transportToApplication)); }
public static void DecompressFile <TSymmetricAlgorithm>(string sourcePath, string destPath, string password = null, PaddingMode paddingMode = PaddingMode.PKCS7, CipherMode cipherMode = CipherMode.CBC) where TSymmetricAlgorithm : SymmetricAlgorithm, new() { var hasPassword = !string.IsNullOrEmpty(password); Action <Stream, Stream> decryptor = (source, dest) => Tools.Streams.Decrypt <TSymmetricAlgorithm>(source, dest, password, null, paddingMode, cipherMode); Action <Stream, Stream> decompressor = Tools.Streams.GZipDecompress; Action <Stream, Stream> noop = (source, dest) => Tools.Streams.RouteStream(source, dest); using (var sourceStream = File.OpenRead(sourcePath)) using (var destStream = File.OpenWrite(destPath)) using (var streamPipeline = new StreamPipeline(hasPassword ? decryptor : noop, decompressor)) streamPipeline.Run(sourceStream, destStream); }
public static string DecompressText <TSymmetricAlgorithm>(byte[] bytes, string password = null, PaddingMode paddingMode = PaddingMode.PKCS7, CipherMode cipherMode = CipherMode.CBC) where TSymmetricAlgorithm : SymmetricAlgorithm, new() { var hasPassword = !String.IsNullOrEmpty(password); Action <Stream, Stream> decryptor = (source, dest) => Streams.Decrypt <TSymmetricAlgorithm>(source, dest, password, null, paddingMode, cipherMode); Action <Stream, Stream> decompressor = Streams.GZipDecompress; Action <Stream, Stream> noop = (source, dest) => Streams.RouteStream(source, dest); using (var sourceStream = new MemoryStream(bytes)) using (var destStream = new MemoryStream()) using (var streamPipeline = new StreamPipeline(hasPassword ? decryptor : noop, decompressor)) { streamPipeline.Run(sourceStream, destStream); return(ConvertToString(destStream.ToArray())); } }
public void Write(ITransporter transporter, StreamPipeline pipeline, Stream content) { //TODO ExceptionHandling transporter.Write(content); }
public Stream Read(ITransporter transporter, StreamPipeline pipeline) { //TODO ExceptionHandling return(transporter.Read()); }
public DataSet Read(IAdapter adapter, StreamPipeline pipeline) { //TODO ExceptionHandling return(adapter.Read()); }
public void Write(IAdapter adapter, StreamPipeline pipeline, DataSet dataSet) { //TODO ExceptionHandling adapter.Write(dataSet); }
public void Write(IFormatter formatter, ITransporter transporter, StreamPipeline pipeline, DataSet dataSet) { //TODO ExceptionHandling transporter.Write(formatter.WriteToStream(dataSet)); }
public DataSet Read(IFormatter formatter, ITransporter transporter, StreamPipeline pipeline) { //TODO ExceptionHandling return(formatter.ReadFromStream(transporter.Read())); }