static async Task Main() { var configuration = ReadConfiguration(); var endpointSettings = configuration.GetSection("lindbakEndpoints").Get <LindbakEndpointsSection>(); if (!endpointSettings.IsValid) { throw new Exception("One or more endpoint settings are not correct"); } var httpClientFactory = new LindbakHttpClientFactory(endpointSettings.CertificateCommonName); var app = new App(httpClientFactory, endpointSettings.FileService); await app.Run(); }
/// <summary> /// Serialize a list of items as JSON lines and return to a compressed stream. /// </summary> /// <typeparam name="T">Type of the items in the list</typeparam> /// <param name="items">A list of items</param> /// <param name="stream">Destination stream. This stream is flushed and position is moved to the start of the stream.</param> public static void WriteAsCompressedJsonLinesTo <T>(this IEnumerable <T> items, Stream stream) { using (var zipStream = new GZipStream(stream, CompressionMode.Compress, leaveOpen: true)) { using (var streamWriter = new StreamWriter(zipStream, Encoding.UTF8, 1024, leaveOpen: true)) { using (var jsonTextWriter = new JsonTextWriter(streamWriter)) { var jsonSerializer = LindbakHttpClientFactory.CreateLindbakCloudBlobSerializer(); foreach (var item in items) { jsonSerializer.Serialize(jsonTextWriter, item); streamWriter.WriteLine(); } } } } stream.Flush(); stream.Seek(0, SeekOrigin.Begin); }
public App(LindbakHttpClientFactory httpClientFactory, LindbakEndpoint fileServiceEndpoint) { _httpClientFactory = httpClientFactory; _fileServiceEndpoint = fileServiceEndpoint; }