public virtual Task<string> ReadLineAsync() { return Task<String>.Factory.StartNew(state => { return ((TextReader)state).ReadLine(); }, this, CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default); }
public static async Task<PemData> TryDecodeAsync(TextReader input) { // Read the header var header = GetBarrierName(await input.ReadLineAsync()); if (header == null) { return null; } // Read the data List<string> dataLines = new List<string>(); string line; while (!(line = await input.ReadLineAsync()).StartsWith("-")) { dataLines.Add(line); } byte[] data; try { data = Convert.FromBase64String(String.Concat(dataLines)); } catch { return null; // Invalid Base64 String! } // Read the footer var footer = GetBarrierName(line); return new PemData(header, data, footer); }