Beispiel #1
0
 public void Touch(ProjectItem item)
 {
     foreach (var processor in _observers)
     {
         processor.NotifyItemChanged(this, item);
     }
 }
Beispiel #2
0
        public void RemoveItem(ProjectItem projectItem)
        {
            if (!_items.Remove(projectItem.Identifier))
                return;

            foreach (var processor in _observers)
            {
                processor.NotifyItemRemoved(this, projectItem);
            }
        }
Beispiel #3
0
        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)));
 }
Beispiel #8
0
 internal void RemoveLinkedItem(ProjectItemLinkDescription description, ProjectItem item2)
 {
     var link = _links.FirstOrDefault(l => l.Description == description && l.ProjectItem == item2);
     if (link != null)
         _links.Remove(link);
 }
Beispiel #9
0
 internal void AddLinkedItem(ProjectItemLinkDescription linkDescription, ProjectItem linkTo)
 {
     _links.Add(new ProjectItemLink(linkDescription, linkTo));
 }
Beispiel #10
0
 public bool TryGetItemById(ProjectItemIdentifier identifier, out ProjectItem item)
 {
     return _items.TryGetValue(identifier, out item);
 }
Beispiel #11
0
 public void RemoveLink(ProjectItem item1, ProjectItemLinkDescription link, ProjectItem item2)
 {
     item1.RemoveLinkedItem(link, item2);
     item2.RemoveLinkedItem(link, item1);
 }
Beispiel #12
0
 public void AddLink(ProjectItem item1, ProjectItemLinkDescription linkDescription, ProjectItem item2)
 {
     item1.AddLinkedItem(linkDescription, item2);
     item2.AddLinkedItem(linkDescription, item1);
 }