public void GetArtifacts(ITextProvider text, ArtifactCollection artifactCollection) { var parser = new MarkdownParser(new TabAwareCharacterStream(text)); CodeBlockInfo lastBlock = null; parser.ArtifactFound += (s, e) => { var cla = e.Artifact as CodeLineArtifact; if (cla != null) { if (lastBlock == null || lastBlock != cla.BlockInfo) { if (lastBlock != null) { artifactCollection.Add(new BlockBoundaryArtifact(lastBlock, BoundaryType.End)); } lastBlock = cla.BlockInfo; artifactCollection.Add(new BlockBoundaryArtifact(cla.BlockInfo, BoundaryType.Start)); } // Don't add artifacts for HTML code lines. //if ((cla.BlockInfo.Language ?? "").StartsWith("htm", StringComparison.OrdinalIgnoreCase)) //{ // cla.BlockInfo.IsExtradited = true; // return; //} } // If we got a non-block artifact after a block end, add the end marker. else if (lastBlock != null && e.Artifact.Start >= lastBlock.OuterEnd.End) { artifactCollection.Add(new BlockBoundaryArtifact(lastBlock, BoundaryType.End)); lastBlock = null; } artifactCollection.Add(e.Artifact); }; parser.Parse(); if (lastBlock != null) { artifactCollection.Add(new BlockBoundaryArtifact(lastBlock, BoundaryType.End)); } }
public void GetArtifacts(ITextProvider text, ArtifactCollection artifactCollection) { var reader = new TextProviderReader(text); var tokenizer = new TemplateTokenizer(reader); foreach (var token in tokenizer.GetTokens()) { if (token.Kind != TemplateTokenKind.Text) { var range = TextRange.FromBounds(token.Start, token.End + 1); var artifact = TemplateArtifact.Create(token.Kind, range, token.IsClosed); artifactCollection.Add(artifact); } } }
public void GetArtifacts(ITextProvider text, ArtifactCollection artifactCollection) { var parser = new MarkdownParser(new TabAwareCharacterStream(text)); CodeBlockInfo lastBlock = null; parser.ArtifactFound += (s, e) => { var cla = e.Artifact as CodeLineArtifact; if (cla != null) { if (lastBlock == null || lastBlock != cla.BlockInfo) { if (lastBlock != null) artifactCollection.Add(new BlockBoundaryArtifact(lastBlock, BoundaryType.End)); lastBlock = cla.BlockInfo; artifactCollection.Add(new BlockBoundaryArtifact(cla.BlockInfo, BoundaryType.Start)); } // Don't add artifacts for HTML code lines. //if ((cla.BlockInfo.Language ?? "").StartsWith("htm", StringComparison.OrdinalIgnoreCase)) //{ // cla.BlockInfo.IsExtradited = true; // return; //} } // If we got a non-block artifact after a block end, add the end marker. else if (lastBlock != null && e.Artifact.Start >= lastBlock.OuterEnd.End) { artifactCollection.Add(new BlockBoundaryArtifact(lastBlock, BoundaryType.End)); lastBlock = null; } artifactCollection.Add(e.Artifact); }; parser.Parse(); if (lastBlock != null) artifactCollection.Add(new BlockBoundaryArtifact(lastBlock, BoundaryType.End)); }
public void loadCollectionsXML() { doc = XDocument.Load(docPath); foreach (var collection in collections) { foreach (XElement e in doc.Root.Descendants(collection).Descendants("item")) { switch (collection) { case "pageone": PageOneCollection.Add(newItem(e, "shippeditems")); break; case "pagetwo": PageTwoCollection.Add(newItem(e, "shippeditems")); break; case "fish": FishCollection.Add(newItem(e, collection)); break; case "artifacts": ArtifactCollection.Add(newItem(e, collection)); break; case "minerals": MineralCollection.Add(newItem(e, collection)); break; case "cooking": CookingCollection.Add(newItem(e, collection)); break; } } } }
public void Add_WhenNullIsSent_ShouldThrowArgumentNullException() { Assert.Throws <ArgumentNullException>(() => _underTest.Add(null)); }