public void Touch(ProjectItem item) { foreach (var processor in _observers) { processor.NotifyItemChanged(this, item); } }
public void RemoveItem(ProjectItem projectItem) { if (!_items.Remove(projectItem.Identifier)) return; foreach (var processor in _observers) { processor.NotifyItemRemoved(this, projectItem); } }
public void AddItem(ProjectItem projectItem) { if (_items.ContainsKey(projectItem.Identifier)) throw new ArgumentException("Project already contains item.", nameof(projectItem)); _items.Add(projectItem.Identifier, projectItem); foreach (var processor in _observers) { processor.NotifyItemAdded(this, projectItem); } }
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; }
private static BuildTaskResult BuildTaskResult(ProjectItem item) { var id = item.Identifier.Identifier.Replace(".html.json", ""); return new BuildTaskResult(new ProjectItemIdentifier(id, "generated_view"), new ProjectItemContentFromAction(item.OpenRead)); }
private static BuildTaskResult BuildTaskResult(ProjectItem item) { var id = item.Identifier.Identifier.Replace(".html.json", ""); return new BuildTaskResult(new ProjectItemIdentifier(id, "thtml"), new ProjectItemContentFromAction(() => Parse(item))); }
internal void RemoveLinkedItem(ProjectItemLinkDescription description, ProjectItem item2) { var link = _links.FirstOrDefault(l => l.Description == description && l.ProjectItem == item2); if (link != null) _links.Remove(link); }
internal void AddLinkedItem(ProjectItemLinkDescription linkDescription, ProjectItem linkTo) { _links.Add(new ProjectItemLink(linkDescription, linkTo)); }
public bool TryGetItemById(ProjectItemIdentifier identifier, out ProjectItem item) { return _items.TryGetValue(identifier, out item); }
public void RemoveLink(ProjectItem item1, ProjectItemLinkDescription link, ProjectItem item2) { item1.RemoveLinkedItem(link, item2); item2.RemoveLinkedItem(link, item1); }
public void AddLink(ProjectItem item1, ProjectItemLinkDescription linkDescription, ProjectItem item2) { item1.AddLinkedItem(linkDescription, item2); item2.AddLinkedItem(linkDescription, item1); }