本文整理汇总了C#中GeneralTree类的典型用法代码示例。如果您正苦于以下问题:C# GeneralTree类的具体用法?C# GeneralTree怎么用?C# GeneralTree使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GeneralTree类属于命名空间,在下文中一共展示了GeneralTree类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Format
public void Format(XLWorkbook workbook, GeneralTree<IDirectoryTreeNode> features)
{
IXLWorksheet tocWorksheet = workbook.AddWorksheet("TOC", 0);
int startRow = 1;
BuildTableOfContents(workbook, tocWorksheet, ref startRow, 1, features);
}
示例2: Format
public XDocument Format(FeatureNode featureNode, GeneralTree<FeatureNode> features)
{
var xmlns = XNamespace.Get("http://www.w3.org/1999/xhtml");
var featureNodeOutputPath = Path.Combine(this.configuration.OutputFolder.FullName, featureNode.RelativePathFromRoot);
var featureNodeOutputUri = new Uri(featureNodeOutputPath);
var container = new XElement(xmlns + "div", new XAttribute("id", "container"));
container.Add(this.htmlHeaderFormatter.Format());
container.Add(this.htmlTableOfContentsFormatter.Format(featureNode.Url, features));
container.Add(this.htmlContentFormatter.Format(featureNode));
container.Add(this.htmlFooterFormatter.Format());
var body = new XElement(xmlns + "body");
body.Add(container);
var head = new XElement(xmlns + "head");
head.Add(new XElement(xmlns + "title", string.Format("{0}", featureNode.Name)));
head.Add(new XElement(xmlns + "link",
new XAttribute("rel", "stylesheet"),
new XAttribute("href", featureNodeOutputUri.MakeRelativeUri(this.htmlResources.MasterStylesheet)),
new XAttribute("type", "text/css")));
var html = new XElement(xmlns + "html",
new XAttribute(XNamespace.Xml + "lang", "en"),
head,
body);
var document = new XDocument(
new XDeclaration("1.0", "UTF-8", null),
new XDocumentType("html", "-//W3C//DTD XHTML 1.0 Strict//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd", string.Empty),
html);
return document;
}
示例3: VisitNodes
private void VisitNodes(GeneralTree<INode> features, INode node)
{
if (node.IsIndexMarkDownNode())
{
return;
}
string nodePath = this.fileSystem.Path.Combine(this.configuration.OutputFolder.FullName, node.RelativePathFromRoot);
string htmlFilePath;
if (node.NodeType == NodeType.Content)
{
htmlFilePath = nodePath.Replace(this.fileSystem.Path.GetExtension(nodePath), ".html");
this.WriteContentNode(features, node, htmlFilePath);
}
else if (node.NodeType == NodeType.Structure)
{
this.fileSystem.Directory.CreateDirectory(nodePath);
htmlFilePath = this.fileSystem.Path.Combine(nodePath, "index.html");
this.WriteContentNode(features, node, htmlFilePath);
}
else
{
// copy file from source to output
this.fileSystem.File.Copy(node.OriginalLocation.FullName, nodePath, overwrite: true);
}
}
示例4: Build
public void Build(GeneralTree<INode> features)
{
if (Log.IsInfoEnabled)
{
Log.Info("Writing Excel workbook to {0}", this.configuration.OutputFolder.FullName);
}
string spreadsheetPath = this.fileSystem.Path.Combine(this.configuration.OutputFolder.FullName, "features.xlsx");
using (var workbook = new XLWorkbook())
{
var actionVisitor = new ActionVisitor<INode>(node =>
{
var featureDirectoryTreeNode =
node as FeatureNode;
if (featureDirectoryTreeNode != null)
{
IXLWorksheet worksheet =
workbook.AddWorksheet(
this.excelSheetNameGenerator.GenerateSheetName(
workbook,
featureDirectoryTreeNode
.Feature));
this.excelFeatureFormatter.Format(
worksheet,
featureDirectoryTreeNode.Feature);
}
});
features.AcceptVisitor(actionVisitor);
this.excelTableOfContentsFormatter.Format(workbook, features);
workbook.SaveAs(spreadsheetPath);
}
}
示例5: BuildListItems
private XElement BuildListItems(GeneralTree<IDirectoryTreeNode> features)
{
XElement container;
if (features.Data.IsContent)
{
container = new XElement("topicref",
new XAttribute("href",
this.ditaMapPathGenerator.GeneratePathToFeature(features.Data)));
}
else
{
container = new XElement("topichead", new XAttribute("navtitle", features.Data.Name));
}
foreach (var childNode in features.ChildNodes)
{
if (childNode.Data.IsContent)
{
container.Add(new XElement("topicref",
new XAttribute("href",
this.ditaMapPathGenerator.GeneratePathToFeature(childNode.Data))));
}
else
{
container.Add(this.BuildListItems(childNode));
}
}
return container;
}
示例6: AddNodeForFile
private XElement AddNodeForFile(XNamespace xmlns, Uri file, GeneralTree<INode> childNode)
{
var xElement = new XElement(xmlns + "li", new XAttribute("class", "file"));
string nodeText = childNode.Data.Name;
if (childNode.Data.OriginalLocationUrl == file)
{
xElement.Add(new XElement(xmlns + "span", new XAttribute("class", "current"), nodeText));
}
else
{
xElement.Add(new XElement(xmlns + "a", new XAttribute("href", childNode.Data.GetRelativeUriTo(file)),
nodeText));
}
var featureNode = childNode.Data as FeatureNode;
if (featureNode != null && this.imageResultFormatter != null)
{
Feature feature = featureNode.Feature;
XElement formatForToC = this.imageResultFormatter.FormatForToC(feature);
if (formatForToC != null)
{
xElement.Add(formatForToC);
}
}
return xElement;
}
示例7: Simple
public void Simple()
{
var root = new GeneralTree<int>(5);
var child1 = new GeneralTree<int>(2);
var child2 = new GeneralTree<int>(3);
var child3 = new GeneralTree<int>(1);
root.Add(child1);
root.Add(child2);
root.Add(child3);
var child4 = new GeneralTree<int>(9);
var child5 = new GeneralTree<int>(12);
var child6 = new GeneralTree<int>(13);
child1.Add(child4);
child1.Add(child5);
child2.Add(child6);
Assert.AreEqual(root.FindNode(target => target == 13), child6);
Assert.AreEqual(root.FindNode(target => target == 2), child1);
Assert.AreEqual(root.FindNode(target => target == 9), child4);
Assert.AreEqual(root.FindNode(target => target == 57), null);
}
示例8: ApplyTestResultsToFeatures
private static void ApplyTestResultsToFeatures(IContainer container, IConfiguration configuration, GeneralTree<INode> features)
{
var testResults = container.Resolve<ITestResults>();
var actionVisitor = new ActionVisitor<INode>(node =>
{
var featureTreeNode = node as FeatureNode;
if (featureTreeNode == null)
{
return;
}
if (configuration.HasTestResults)
{
SetResultsAtFeatureLevel(featureTreeNode, testResults);
SetResultsForIndividualScenariosUnderFeature(featureTreeNode, testResults);
}
else
{
featureTreeNode.Feature.Result = TestResult.Inconclusive;
}
});
features.AcceptVisitor(actionVisitor);
}
示例9: Crawl
private GeneralTree<IDirectoryTreeNode> Crawl(DirectoryInfo directory, IDirectoryTreeNode rootNode)
{
IDirectoryTreeNode currentNode =
featureNodeFactory.Create(rootNode != null ? rootNode.OriginalLocation : null, directory);
if (rootNode == null)
{
rootNode = currentNode;
}
var tree = new GeneralTree<IDirectoryTreeNode>(currentNode);
bool isRelevantFileFound = false;
foreach (FileInfo file in directory.GetFiles().Where(file => relevantFileDetector.IsRelevant(file)))
{
isRelevantFileFound = true;
IDirectoryTreeNode node = featureNodeFactory.Create(rootNode.OriginalLocation, file);
tree.Add(node);
}
bool isRelevantDirectoryFound = false;
foreach (DirectoryInfo subDirectory in directory.GetDirectories())
{
GeneralTree<IDirectoryTreeNode> subTree = Crawl(subDirectory, rootNode);
if (subTree != null)
{
isRelevantDirectoryFound = true;
tree.Add(subTree);
}
}
if (!isRelevantFileFound && !isRelevantDirectoryFound) return null;
return tree;
}
示例10: Format
public XDocument Format(IDirectoryTreeNode featureNode, GeneralTree<IDirectoryTreeNode> features, DirectoryInfo rootFolder)
{
var xmlns = HtmlNamespace.Xhtml;
var featureNodeOutputPath = Path.Combine(this.configuration.OutputFolder.FullName, featureNode.RelativePathFromRoot);
var featureNodeOutputUri = new Uri(featureNodeOutputPath);
var container = new XElement(xmlns + "div", new XAttribute("id", "container"));
container.Add(this.htmlHeaderFormatter.Format());
container.Add(this.htmlTableOfContentsFormatter.Format(featureNode.OriginalLocationUrl, features, rootFolder));
container.Add(this.htmlContentFormatter.Format(featureNode, features));
container.Add(this.htmlFooterFormatter.Format());
var body = new XElement(xmlns + "body");
body.Add(container);
var head = new XElement(xmlns + "head");
head.Add(new XElement(xmlns + "title", string.Format("{0}", featureNode.Name)));
head.Add(new XElement(xmlns + "link",
new XAttribute("rel", "stylesheet"),
new XAttribute("href", featureNodeOutputUri.MakeRelativeUri(this.htmlResources.MasterStylesheet)),
new XAttribute("type", "text/css")));
head.Add(new XElement(xmlns + "link",
new XAttribute("rel", "stylesheet"),
new XAttribute("href", featureNodeOutputUri.MakeRelativeUri(this.htmlResources.PrintStylesheet)),
new XAttribute("type", "text/css"),
new XAttribute("media", "print")));
head.Add(new XElement(xmlns + "script",
new XAttribute("src", featureNodeOutputUri.MakeRelativeUri(this.htmlResources.jQueryScript)),
new XAttribute("type", "text/javascript"),
new XText(string.Empty)));
head.Add(new XElement(xmlns + "script",
new XAttribute("src", featureNodeOutputUri.MakeRelativeUri(this.htmlResources.jQueryDataTablesScript)),
new XAttribute("type", "text/javascript"),
new XText(string.Empty)));
head.Add(new XElement(xmlns + "script",
new XAttribute("src", featureNodeOutputUri.MakeRelativeUri(this.htmlResources.AdditionalScripts)),
new XAttribute("type", "text/javascript"),
new XText(string.Empty)));
head.Add(new XElement(xmlns + "script",
new XAttribute("type", "text/javascript"),
documentReady));
var html = new XElement(xmlns + "html",
new XAttribute(XNamespace.Xml + "lang", "en"),
head,
body);
var document = new XDocument(
new XDeclaration("1.0", "UTF-8", null),
new XDocumentType("html", "-//W3C//DTD XHTML 1.0 Strict//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd", string.Empty),
html);
return document;
}
示例11: BuildListItems
private XElement BuildListItems(XNamespace xmlns, Uri file, GeneralTree<FeatureNode> features)
{
var ul = new XElement(xmlns + "ul", new XAttribute("class", "features"));
foreach (var childNode in features.ChildNodes)
{
if (childNode.Data.IsContent)
{
ul.Add(new XElement(xmlns + "div",
new XAttribute("class", "file"),
new XElement(xmlns + "li",
new XElement(xmlns + "a",
new XAttribute("href", childNode.Data.GetRelativeUriTo(file)), childNode.Data.Name.ExpandWikiWord()))));
}
else
{
ul.Add(new XElement(xmlns + "li",
new XElement(xmlns + "div",
new XAttribute("class", "directory"),
new XText(childNode.Data.Name.ExpandWikiWord())
), BuildListItems(xmlns, file, childNode)));
}
}
return ul;
}
示例12: Build
public void Build(GeneralTree<IDirectoryTreeNode> features)
{
if (log.IsInfoEnabled)
{
log.InfoFormat("Writing DHTML files to {0}", this.configuration.OutputFolder.FullName);
}
var resource = new DhtmlResourceSet(configuration);
log.Info("DeployZippedDhtmlResourcesForExtraction");
DeployZippedDhtmlResourcesForExtraction(resource);
log.Info("UnzipDhtmlResources");
UnzipDhtmlResources(resource);
log.Info("UtilizeJsonBuilderToDumpJsonFeatureFileNextToDthmlResources");
UtilizeJsonBuilderToDumpJsonFeatureFileNextToDthmlResources(features);
log.Info("Tweak Json file");
TweakJsonFile();
log.Info("CleanupZippedDhtmlResources");
CleanupZippedDhtmlResources(resource);
}
示例13: Simple
public void Simple()
{
var generalTree = new GeneralTree<int>(4);
Assert.IsFalse(generalTree.IsReadOnly);
generalTree = GetTestTree();
Assert.IsFalse(generalTree.IsReadOnly);
}
示例14: Build
public void Build(GeneralTree<IDirectoryTreeNode> features)
{
var map = new XElement("map", new XAttribute("title", "Features"), new XAttribute("id", "features"),
this.BuildListItems(features));
var document = new XDocument(
new XDocumentType("map", "-//OASIS//DTD DITA Map//EN", "map.dtd", string.Empty), map);
document.Save(Path.Combine(this.configuration.OutputFolder.FullName, "features.ditamap"));
}
示例15: Get
public void Get()
{
var root = new GeneralTree<int>(5) { 2, 3 };
root.GetChild(0).Parent = root.GetChild(1);
Assert.AreSame(((ITree<int>)root.GetChild(0)).Parent, root);
}