public IEnumerable <IDelta> DetermineDeltas(TopicToken originalRoot) { var original = originalRoot.Find(Id); if (original == null) { yield return(new NewTopic(this)); } else { if (original.File != File) { yield return(new MoveTopic(original.File, File)); } if (original.Title != Title) { yield return(new RewriteTitle(File, Title)); } if (original.Url != Url) { yield return(new RewriteUrl(File, Url)); } } }
private void findDeletedTopics(TopicToken original, TopicToken @new) { var deletedTopics = original.All().Where(x => @new.Find(x.Id) == null) .Select(x => new DeleteTopic(x)); _deltas.AddRange(deletedTopics); }
public TopicTreeTag(TopicToken token) : base("div") { AddClass("dd"); Id("topic-tree"); Append(new TopicNodeTag(new [] { token })); }
public static TopicToken LoadIndex(string directory) { var root = TopicLoader.LoadFromFolder(directory); var token = new TopicToken(root.Index); token.Key = "index"; return(token); }
public void RewriteTopicStructure(string projectName, TopicToken newStructure) { var original = _tokens[projectName]; var collector = new DeltaCollector(original, newStructure); collector.ExecuteDeltas(); // Want the new one in on the next try. _tokens.Remove(projectName); }
private void findNewAndDeletedFolders(TopicToken original, TopicToken @new) { var oldFolders = original.All().Select(x => x.Folder).Distinct().ToList(); var newFolders = @new.All().Select(x => x.Folder).Distinct().ToList(); var deletedFolders = oldFolders.Where(x => !newFolders.Contains(x)).Select(x => new DeleteFolder(x)); _deltas.AddRange(deletedFolders); var addedFolders = newFolders.Where(x => !oldFolders.Contains(x)).Select(x => new CreateFolder(x)); _deltas.AddRange(addedFolders); }
public DeltaCollector(TopicToken original, TopicToken @new) { @new.DeterminePaths(original.Folder); findDeletedTopics(original, @new); findNewAndDeletedFolders(original, @new); @new.All().Each(x => { var topicDeltas = x.DetermineDeltas(original); _deltas.AddRange(topicDeltas); }); }
public TopicToken Clone() { var clone = new TopicToken { Url = Url, Key = Key, FullKey = FullKey, Title = Title, File = File, Folder = Folder, Id = Id }; clone.Children.AddRange(Children.Select(x => x.Clone())); clone.assignOrders(); return(clone); }
public TopicListItemTag(TopicToken token) : base("li") { AddClass("dd-item"); AddClass("dd3-item"); Data("id", token.Id); Data("title", token.Title); Data("url", token.Url); Data("key", token.Key); Add("div").AddClass("dd-handle").AddClass("dd3-handle"); var contentTag = Add("div").AddClass("dd3-content"); contentTag.Add("span").AddClass("topic-title").Text(token.Title); if (token.Key != "index") { contentTag.Add("a").AddClass("close").Data("dismiss", "alert").Text("×").Encoded(false); } Append(new TopicNodeTag(token.Children)); }
public AjaxContinuation post_project_ProjectName(TopicToken topic) { if (_lastTimestamp == _reloaded.Timestamp.ToString()) { return(AjaxContinuation.Successful()); } var existing = _tokenCache.TopicStructureFor(topic.ProjectName); var collector = new DeltaCollector(existing, topic); var orderedDeltas = collector.OrderedDeltas().ToArray(); orderedDeltas.Each(x => Debug.WriteLine(x)); collector.ExecuteDeltas(); Task.Factory.StartNew(() => { EventAggregator.SendMessage(new RecycleApplication()); }); _lastTimestamp = _reloaded.Timestamp.ToString(); return(AjaxContinuation.Successful()); }
public NewTopic(TopicToken token) { _token = token; }
public void AddChild(TopicToken child) { Children.Add(child); assignOrders(); }
protected bool Equals(TopicToken other) { return(Id.Equals(other.Id)); }
public DeleteTopic(TopicToken token) { _file = token.File; }