本文整理汇总了C#中TreeList.AddBranch方法的典型用法代码示例。如果您正苦于以下问题:C# TreeList.AddBranch方法的具体用法?C# TreeList.AddBranch怎么用?C# TreeList.AddBranch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TreeList
的用法示例。
在下文中一共展示了TreeList.AddBranch方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MakeTables
void MakeTables(TreeList<CellBase> result)
{
string leader = string.Empty;
TreeList<CellBase> table = null;
scanner.MoveNext();
do {
if (scanner.Current.Type == TokenType.Leader) {
leader = scanner.Current.Content;
scanner.MoveNext();
}
else if (scanner.Current.Type == TokenType.Word) {
table = new TreeList<CellBase>(new CellBase(string.Empty));
table.Value.SetAttribute(CellAttribute.StartTag, "<p>");
table.Value.SetAttribute(CellAttribute.EndTag, "</p>");
if (leader.Length > 0) {
table.Value.SetAttribute(CellAttribute.Leader, leader);
leader = string.Empty;
}
result.AddBranch(table);
MakeRows(table);
if (scanner.Current.Type == TokenType.Newline) scanner.MoveNext();
}
else {
scanner.MoveNext();
}
} while (scanner.Current.Type != TokenType.End);
if (table != null && scanner.Current.Content.Length > 0) {
table.Value.SetAttribute(CellAttribute.Trailer, scanner.Current.Content);
}
}
示例2: MakeRows
void MakeRows(TreeList<CellBase> table) {
do {
var row = new TreeList<CellBase>(new CellBase(string.Empty));
row.Value.SetAttribute(CellAttribute.StartTag, startTags[1]);
row.Value.SetAttribute(CellAttribute.EndTag, endTags[1]);
table.AddBranch(row);
MakeCells(row);
if (scanner.Current.Type == TokenType.Newline) scanner.MoveNext();
} while (scanner.Current.Type == TokenType.BeginCell || scanner.Current.Type == TokenType.Word);
}
示例3: MakeCells
void MakeCells(TreeList<CellBase> row)
{
while (scanner.Current.Type == TokenType.Word) {
var cell = new TreeList<CellBase>(new CellBase(scanner.Current.Content));
cell.Value.SetAttribute(CellAttribute.Body, scanner.Current.Content);
cell.Value.SetAttribute(CellAttribute.StartTag, "<span>");
cell.Value.SetAttribute(CellAttribute.EndTag, "</span> ");
row.AddBranch(cell);
scanner.MoveNext();
}
}
示例4: Parse
public Tree<CellBase> Parse(string input) {
var alternationParser = new AlternationParser();
var cells = new ListParser("td", alternationParser, false);
var rows = new ListParser("tr", cells, true);
var tables = new ListParser("table", rows, true);
var items = new ListParser("li", alternationParser, false);
var lists = new ListParser("ul", items, true);
alternationParser.ChildParsers = new [] {tables, lists};
var root = new CellBase(string.Empty, "div");
var result = new TreeList<CellBase>(root);
foreach (Tree<CellBase> branch in tables.Parse(new LexicalAnalyzer(input))) result.AddBranch(branch);
return result;
}
示例5: MakeCells
void MakeCells(TreeList<CellBase> row)
{
while (scanner.Current.Type == TokenType.BeginCell || scanner.Current.Type == TokenType.Word) {
var cell = new TreeList<CellBase>(new CellBase(scanner.Current.Content));
cell.Value.SetAttribute(CellAttribute.StartTag, startTags[2]);
cell.Value.SetAttribute(CellAttribute.EndTag, endTags[2]);
if (scanner.Current.Type == TokenType.BeginCell) {
MakeTables(cell);
}
else if (scanner.Current.Type == TokenType.Word) {
cell.Value.SetAttribute(CellAttribute.Body, HttpUtility.HtmlEncode(scanner.Current.Content));
}
row.AddBranch(cell);
scanner.MoveNext();
}
}
示例6: ParseElement
Tree<CellBase> ParseElement(LexicalAnalyzer theAnalyzer) {
string tag = theAnalyzer.Token;
string leader = theAnalyzer.Leader;
theAnalyzer.PushEnd("/" + myKeyword);
List<Tree<CellBase>> children = myChildParser.Parse(theAnalyzer);
if (IRequireChildren && children.Count == 0) {
throw new ApplicationException(string.Format("Can't find tag: {0}", myChildParser.Keyword));
}
theAnalyzer.PopEnd();
theAnalyzer.GoToNextToken("/" + myKeyword);
if (theAnalyzer.Token.Length == 0) throw new ApplicationException("expected /" + myKeyword + " tag");
var result = new TreeList<CellBase>(new CellBase(HtmlToText(theAnalyzer.Leader)));
result.Value.SetAttribute(CellAttribute.Body, theAnalyzer.Leader);
result.Value.SetAttribute(CellAttribute.EndTag, theAnalyzer.Token);
if (leader.Length > 0) result.Value.SetAttribute(CellAttribute.Leader, leader);
result.Value.SetAttribute(CellAttribute.StartTag, tag);
foreach (Tree<CellBase> child in children) result.AddBranch(child);
return result;
}