private static async Task<Stream> Parse(ProjectItem item) { using (var stream = new StreamReader(await item.OpenRead())) { var text = stream.ReadToEnd(); var tree = new Parser(new HandlebarsParser()).Parse(new Lexer().Tokenize(text)); var memoryStream = new MemoryStream(); var streamWriter = new StreamWriter(memoryStream); new JsonSerializer().Serialize(streamWriter, tree); streamWriter.Flush(); memoryStream.Seek(0, SeekOrigin.Begin); return memoryStream; } }
private static async Task<Stream> Do(ProjectItem projectItem) { string content; using (var reader = new StreamReader(await projectItem.OpenRead().ConfigureAwait(false))) { content = await reader.ReadToEndAsync().ConfigureAwait(false); } var minifier = new Minifier(); content = minifier.MinifyJavaScript(content); var stream = new MemoryStream(); var writer = new StreamWriter(stream); writer.Write(content); writer.Flush(); stream.Seek(0, SeekOrigin.Begin); return stream; }