本文整理汇总了C#中NodeCollection.Add方法的典型用法代码示例。如果您正苦于以下问题:C# NodeCollection.Add方法的具体用法?C# NodeCollection.Add怎么用?C# NodeCollection.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodeCollection
的用法示例。
在下文中一共展示了NodeCollection.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetNodes
public string GetNodes(string node)
{
NodeCollection nodes = new NodeCollection(false);
if (!string.IsNullOrEmpty(node))
{
for (int i = 1; i < 6; i++)
{
Node asyncNode = new Node();
asyncNode.Text = node + i;
asyncNode.NodeID = node + i;
nodes.Add(asyncNode);
}
for (int i = 6; i < 11; i++)
{
Node treeNode = new Node();
treeNode.Text = node + i;
treeNode.NodeID = node + i;
treeNode.Leaf = true;
nodes.Add(treeNode);
}
}
return nodes.ToJson();
}
示例2: BuildFirstLevel
public static NodeCollection BuildFirstLevel()
{
string path = HttpContext.Current.Server.MapPath("~/Examples/");
DirectoryInfo root = new DirectoryInfo(path);
DirectoryInfo[] folders = root.GetDirectories();
folders = UIHelpers.SortFolders(root, folders);
NodeCollection nodes = new NodeCollection(false);
foreach (DirectoryInfo folder in folders)
{
if ((folder.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden ||
excludeList.Contains(folder.Name) || folder.Name.StartsWith("_"))
{
continue;
}
ExampleConfig cfg = new ExampleConfig(folder.FullName + "\\config.xml", false);
string iconCls = string.IsNullOrEmpty(cfg.IconCls) ? "" : cfg.IconCls;
Node node = new Node();
node.Text = UIHelpers.MarkNew(folder.FullName, folder.Name.Replace("_", " "));
node.IconCls = iconCls;
string url = UIHelpers.PhysicalToVirtual(folder.FullName + "/");
node.NodeID = "e" + Math.Abs(url.ToLower().GetHashCode());
nodes.Add(node);
}
return nodes;
}
示例3: GetNodes
public ActionResult GetNodes(string node)
{
if (!string.IsNullOrEmpty(node))
{
NodeCollection nodes = new NodeCollection();
SiteMapNode siteMapNode = SiteMap.Provider.FindSiteMapNodeFromKey(node);
if (siteMapNode == null)
{
return this.Store(nodes);
}
SiteMapNodeCollection children = siteMapNode.ChildNodes;
if (children != null && children.Count > 0)
{
foreach (SiteMapNode mapNode in siteMapNode.ChildNodes)
{
nodes.Add(NodeHelper.CreateNodeWithOutChildren(mapNode));
}
}
return this.Store(nodes);
}
return new HttpStatusCodeResult(500);
}
示例4: FlattenChildren
/// <summary>
/// Get all the children recursive and flattens it into the given list.
/// </summary>
/// <param name="parent">The parent.</param>
/// <param name="listToFill">The list to fill.</param>
private void FlattenChildren(Node parent, ref NodeCollection listToFill)
{
listToFill.Add(parent);
foreach (var child in parent.Children)
{
this.FlattenChildren(child, ref listToFill);
}
}
示例5: GetNodes
public StoreResult GetNodes(string node)
{
NodeCollection nodes = new NodeCollection(false);
string prefix = DateTime.Now.Second + "_";
for (int i = 0; i < 10; i++)
{
Node newNode = new Node();
newNode.NodeID = i.ToString();
newNode.Text = prefix + i;
newNode.Leaf = true;
nodes.Add(newNode);
}
return this.Store(nodes);
}
示例6: LoadPages
public ActionResult LoadPages(string node)
{
NodeCollection result = null;
if (node == "_root")
{
result = SiteMapModel.CreateNode(SiteMap.RootNode).Children;
}
else
{
SiteMapNode siteMapNode = SiteMap.Provider.FindSiteMapNodeFromKey(node);
SiteMapNodeCollection children = siteMapNode.ChildNodes;
result = new NodeCollection();
if (children != null && children.Count > 0)
{
foreach (SiteMapNode mapNode in siteMapNode.ChildNodes)
{
result.Add(SiteMapModel.CreateNodeWithOutChildren(mapNode));
}
}
}
return this.Store(result);
}
示例7: ListToNode
private void ListToNode(IEnumerable<Category> lists, NodeCollection nodes)
{
foreach (Category tasksList in lists)
{
Node node = new Node();
node.NodeID = tasksList.ID.ToString();
node.Text = tasksList.Name;
node.Leaf = !tasksList.IsFolder;
node.IconCls = tasksList.IsFolder ? "icon-folder" : "icon-category";
node.CustomAttributes.Add(new ConfigItem("isFolder", JSON.Serialize(tasksList.IsFolder), ParameterMode.Raw));
if (!tasksList.IsFolder)
{
node.AllowDrop = false;
}
node.Expanded = tasksList.IsFolder;
if (tasksList.Categories.Count > 0)
{
this.ListToNode(tasksList.Categories, node.Children);
}
else if(!node.Leaf)
{
node.EmptyChildren = true;
}
nodes.Add(node);
}
}
示例8: InsertToken
private void InsertToken(NodeCollection nodeCollection, AuthorityTokenTableEntry token, int depth)
{
// check if a node for this path segment already exists in the tree
PathSegment segment = token.Path.Segments[depth];
Node node = CollectionUtils.SelectFirst<Node>(nodeCollection,
delegate(Node n)
{
return n.Text == segment.LocalizedText;
});
// if not, create the node
if(node == null)
{
node = new Node(segment.LocalizedText);
node.CheckStateChanged += new EventHandler(node_CheckStateChanged);
nodeCollection.Add(node);
}
// if this is a leaf node, set the properties of the tree node accordingly
if (segment == token.Path.LastSegment)
{
node.Tag = token;
node.Tooltip = token.Description;
node.CheckState = token.Selected ? CheckState.Checked : CheckState.Unchecked;
// addition of this leaf may need to alter the check state of the parent
if (node.Parent != null)
{
PropagateCheckStateUp(node.Parent);
}
}
else
{
// otherwise, recur until we hit the leaf
InsertToken(node.Nodes, token, depth + 1);
}
}
示例9: ParsePossibleAttributes
private void ParsePossibleAttributes(bool isGlobal)
{
while (curtok.ID == TokenID.LBracket)
{
// is it neccessary to save current typeparameter
// because an attribute can be declared for a type parameter
// so if we do not do that, the typeparameter will be considered
// as the type parameter of his attribute declaration ...
// i.e. :
// class cons <[GenPar] A, [GenPar] B>{}
//
// without backup, A is considered as the type parameter of GenPar,
// and the parser will generate the wrong outpu : class cons <[GenPar<A>]...
List<TypeParameterNode> backupTypeParameters = curTypeParameters;
curTypeParameters = new List<TypeParameterNode>();
Dictionary<string, Constraint> backupConstraints = curTypeParameterConstraints;
curTypeParameterConstraints = new Dictionary<string, Constraint>();
Advance(); // advance over LBracket token
curmods = ParseAttributeModifiers();
if (isGlobal && curmods == Modifier.GlobalAttributeMods)
{
// nothing to check, globally positioned attributes can still apply to namespaces etc
}
else
{
uint attribMask = ~(uint)Modifier.AttributeMods;
if (((uint)curmods & attribMask) != (uint)Modifier.Empty)
ReportError("Attribute contains illegal modifiers.");
}
AttributeNode node = new AttributeNode(curtok);
Modifier curAttribMods = curmods;
curmods = Modifier.Empty;
if (curAttribMods != Modifier.Empty)
{
AssertAndAdvance(TokenID.Colon);
}
curAttributes.Add(node);
node.Modifiers = curAttribMods;
while (curtok.ID != TokenID.RBracket && curtok.ID != TokenID.Eof)
{
node.Name = ParseQualifiedIdentifier(true, false, false);
if (curtok.ID == TokenID.LParen)
{
// named argument
//gtest-286, line 16
// [Test(typeof(C<string>))]
// public static void Foo()
// {
// }
//
// the attribute is applied to the type parameter, so we back up it.
NodeCollection<AttributeNode> backupAttributes = curAttributes;
curAttributes = new NodeCollection<AttributeNode>();
// has attribute arguments
Advance(); // over lparen
// named args are ident = expr
// positional args are just expr
while (curtok.ID != TokenID.RParen && curtok.ID != TokenID.Eof)
{
AttributeArgumentNode aNode = new AttributeArgumentNode(curtok);
if ( curTokNode != null
&& curTokNode.Next != null && curTokNode.Next.Next != null &&
curtok.ID == TokenID.Ident &&
curTokNode.Value.ID == TokenID.Equal)
{
aNode.ArgumentName = (IdentifierExpression)ParseIdentifierOrKeyword(false, false, false, false);
Advance(); // over '='
}
aNode.Expression = ParseExpression();
node.Arguments.Add(aNode);
if (curtok.ID == TokenID.Comma)
{
Advance(); // over comma
}
}
AssertAndAdvance(TokenID.RParen); // over rparen
// restore the backup
curAttributes = backupAttributes;
if ( curTokNode != null && curTokNode.Next != null && curTokNode.Next.Next != null &&
curtok.ID == TokenID.Comma &&
curTokNode.Value.ID != TokenID.RBracket)
{
Advance(); // over comma
node = new AttributeNode(curtok);
curAttributes.Add(node);
//.........这里部分代码省略.........
示例10: BuildAreasLevel
private static NodeCollection BuildAreasLevel()
{
string path = HttpContext.Current.Server.MapPath(ExamplesModel.ExamplesRoot);
DirectoryInfo root = new DirectoryInfo(path);
DirectoryInfo[] folders = root.GetDirectories();
folders = ExamplesModel.SortFolders(root, folders);
NodeCollection nodes = new NodeCollection(false);
var staticIcons = new StaticNodeIcon(path);
foreach (DirectoryInfo folder in folders)
{
if ((folder.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden ||
excludeList.Contains(folder.Name) || folder.Name.StartsWith("_"))
{
continue;
}
ExampleConfig cfg = new ExampleConfig(folder.FullName + "\\config.xml");
string iconCls = string.IsNullOrEmpty(cfg.IconCls) ? "" : cfg.IconCls;
Node node = null;
var index = folder.Name.IndexOf('_');
if (cfg.MainGroup || index < 0)
{
node = new Node();
node.NodeID = BaseControl.GenerateID();
node.Text = folder.Name.Replace("_", " ");
nodes.Add(node);
if (String.IsNullOrWhiteSpace(iconCls)) {
staticIcons.TryGetIconCLS(out iconCls, folder.Name);
}
node.IconCls = iconCls;
if (ExamplesModel.IsNew(folder.FullName))
{
node.CustomAttributes.Add(new ConfigItem("isNew", "true", ParameterMode.Raw));
}
}
else
{
string otherIconCls;
var mainGroupName = folder.Name.Substring(0, index);
node = nodes.FirstOrDefault(n => n.Text == mainGroupName);
if (node == null)
{
node = new Node();
node.NodeID = BaseControl.GenerateID();
node.Text = mainGroupName;
nodes.Add(node);
}
if (staticIcons.TryGetIconCLS(out otherIconCls, mainGroupName))
{
node.IconCls = otherIconCls;
}
if (ExamplesModel.IsNew(folder.FullName) && !node.CustomAttributes.Contains("isNew"))
{
node.CustomAttributes.Add(new ConfigItem("isNew", "true", ParameterMode.Raw));
}
var groupNode = new Node();
var subGroupNodeName = folder.Name.Substring(index + 1);
groupNode.NodeID = BaseControl.GenerateID();
groupNode.Text = subGroupNodeName.Replace("_", " ");
if (iconCls.IsNotEmpty())
{
groupNode.IconCls = iconCls;
}
else if (staticIcons.TryGetIconCLS(out otherIconCls, mainGroupName, subGroupNodeName))
{
groupNode.IconCls = otherIconCls;
}
if (ExamplesModel.IsNew(folder.FullName) && !groupNode.CustomAttributes.Contains("isNew"))
{
groupNode.CustomAttributes.Add(new ConfigItem("isNew", "true", ParameterMode.Raw));
}
node.Children.Add(groupNode);
node = groupNode;
}
ExamplesModel.BuildViewsLevel(folder, node);
}
return nodes;
}
示例11: ParseArgs
private NodeCollection<ArgumentNode> ParseArgs()
{
AssertAndAdvance(TokenID.LParen);
if (curtok.ID == TokenID.RParen)
{
Advance();
return null;
}
bool hasComma;
NodeCollection<ArgumentNode> result = new NodeCollection<ArgumentNode>();
do
{
ArgumentNode node = new ArgumentNode(curtok);
result.Add(node);
if (curtok.ID == TokenID.Ref)
{
node.IsRef = true;
Advance();
}
else if (curtok.ID == TokenID.Out)
{
node.IsOut = true;
Advance();
}
node.Expression = ParseExpression();
hasComma = false;
if (curtok.ID == TokenID.Comma)
{
Advance();
hasComma = true;
}
}
while (hasComma);
AssertAndAdvance(TokenID.RParen);
return result;
}
示例12: ParseStatement
// statements
private void ParseStatement(NodeCollection<StatementNode> node)
{
// label ident : colon
// localDecl type : ident
// block LCurly
// empty Semi
// expression
// -invoke pexpr : LParen
// -objCre new : type
// -assign uexpr : assignOp
// -postInc pexpr : ++
// -postDec pexpr : --
// -preInc ++ : uexpr
// -preDec -- : uexpr
//
// selection if : LParen
// switch : LParen
//
// iteration while : LParen
// do : LParen
// for : LParen
// foreach : LParen
//
// jump break : Semi
// continue: Semi
// goto : ident | case | default
// return : expr
// throw : expr
//
// try try : block
// checked checked : block
// unchecked unchecked : block
// lock lock : LParen
// using using : LParen
switch (curtok.ID)
{
case TokenID.LCurly: // block
BlockStatement newBlock = new BlockStatement(isUnsafe > 0, curtok);
newBlock.IsUnsafe = isUnsafe > 0;
node.Add(newBlock);
ParseBlock(newBlock);
break;
case TokenID.Semi: // empty statement
node.Add(new StatementNode(curtok));
Advance();
break;
case TokenID.If: // If statement
node.Add(ParseIf());
break;
case TokenID.Switch: // Switch statement
node.Add(ParseSwitch());
break;
case TokenID.While: // While statement
node.Add(ParseWhile());
break;
case TokenID.Do: // Do statement
node.Add(ParseDo());
break;
case TokenID.For: // For statement
node.Add(ParseFor());
break;
case TokenID.Foreach: // Foreach statement
node.Add(ParseForEach());
break;
case TokenID.Break: // Break statement
node.Add(ParseBreak());
break;
case TokenID.Continue: // Continue statement
node.Add(ParseContinue());
break;
case TokenID.Goto: // Goto statement
node.Add(ParseGoto());
break;
case TokenID.Return: // Return statement
node.Add(ParseReturn());
break;
case TokenID.Throw: // Throw statement
node.Add(ParseThrow());
break;
case TokenID.Try: // Try statement
node.Add(ParseTry());
break;
case TokenID.Checked: // Checked statement
node.Add(ParseChecked());
break;
case TokenID.Unchecked: // Unchecked statement
node.Add(ParseUnchecked());
break;
case TokenID.Lock: // Lock statement
node.Add(ParseLock());
break;
case TokenID.Using: // Using statement
node.Add(ParseUsing());
break;
case TokenID.Const:
isLocalConst = true;
Advance();
break;
//.........这里部分代码省略.........
示例13: FindBestPath
/// <summary>
/// Finds the Best path between 2 points
/// </summary>
/// <param name="topologyName">[in] Name of existing topology.</param>
/// <returns>
/// Returns true if successful.
/// </returns>
private bool FindBestPath(string topologyName)
{
// Get the Topology object for the specified Topology
TopologyModel mapTopology = null;
MapApplication mapApp = HostMapApplicationServices.Application;
Topologies topos = mapApp.ActiveProject.Topologies;
if (topos.Exists(topologyName))
{
mapTopology = topos[topologyName];
}
else
{
Utility.AcadEditor.WriteMessage(string.Format("\nERROR: The Topology {0} doesn't exit!", topologyName));
return false;
}
// Required for the TraceBestPath Function
ElementCollection objectsOnPath = null;
TraceParameters objTraceParams = new TraceParameters(
0, // MinResistance,
100000, // MaxResistance,
null, // NodeResistanceExpression,
null, // LinkDirectionExpression,
null, // LinkResistanceExpression,
null, // LinkReverseResistanceExpression,
false, // UseReverseDirection,
"Result",// Name
"Test"); // Description
// Open the topology for read
try
{
mapTopology.Open(Autodesk.Gis.Map.Topology.OpenMode.ForRead);
}
catch (MapException e)
{
Utility.AcadEditor.WriteMessage(string.Format("\nERROR: Unable to open Topology {0} for read with error code: {1}.", topologyName, e.ErrorCode));
return false;
}
try
{
// Select the starting node
string promptString = "\nSelect the Start Node:";
Node startNode = null;
if (!SelectNode(ref startNode, promptString, mapTopology))
{
Utility.AcadEditor.WriteMessage("\nERROR: A valid Start Node was not selected.");
return false;
}
// Select the end node
Node endNode = null;
promptString = "\nSelect the End Node:";
if (!SelectNode(ref endNode, promptString, mapTopology))
{
Utility.AcadEditor.WriteMessage("\nERROR: A valid End Node was not selected.");
return false;
}
// Select the intermediate nodes
NodeCollection intermediates = new NodeCollection();
Node intermediateNode = null;
promptString = "\nSelect an Intermediate Node:";
while (SelectNode(ref intermediateNode, promptString, mapTopology))
{
intermediates.Add(intermediateNode);
intermediateNode = null;
}
// Find the best path and output it as a new topology called result
objectsOnPath = mapTopology.TraceBestPath(startNode, endNode, intermediates, objTraceParams);
Utility.AcadEditor.WriteMessage("\nThe best path function has created a Topology named Result.");
Utility.SendCommand("_regen\n");
return true;
}
catch (MapException e)
{
if (2001 == e.ErrorCode)
{
Utility.AcadEditor.WriteMessage("\nERROR: Topology Result already exists.");
}
else
{
Utility.AcadEditor.WriteMessage(string.Format("\nERROR: Unable to find the best path with error code: {0}.", e.ErrorCode));
}
return false;
}
finally
{
mapTopology.Close();
//.........这里部分代码省略.........
示例14: ParseParamList
private NodeCollection<ParamDeclNode> ParseParamList(TokenID openToken, TokenID closeToken)
{
AssertAndAdvance(openToken);
if (curtok.ID == closeToken)
{
Advance();
return null;
}
NodeCollection<ParamDeclNode> result = new NodeCollection<ParamDeclNode>();
bool isParams;
bool hasComma;
do
{
ParamDeclNode node = new ParamDeclNode(curtok);
result.Add(node);
isParams = false;
ParsePossibleAttributes(false);
if (isAnonynous > 0
&& curAttributes.Count > 0)
{
ReportError("Attributes are not allowed for anonymous delegate's parameters.");
}
if (curtok.ID == TokenID.Ref)
{
node.Modifiers |= Modifier.Ref;
Advance();
}
else if (curtok.ID == TokenID.Out)
{
node.Modifiers |= Modifier.Out;
Advance();
}
else if (curtok.ID == TokenID.Params)
{
if (isAnonynous > 0)
{
ReportError("Params parameter are not allowed for anonymous delegate.");
}
isParams = true;
node.Modifiers |= Modifier.Params;
Advance();
}
node.Type = ParseType();
if (isParams)
{
// ensure is array type
}
if (curtok.ID == TokenID.Ident)
{
node.Name = ((IdentifierExpression)ParseIdentifierOrKeyword(false, false, false, false)).Identifier;//strings[curtok.Data];
}
hasComma = false;
if (curtok.ID == TokenID.Comma)
{
Advance();
hasComma = true;
}
}
while (!isParams && hasComma);
AssertAndAdvance(closeToken);
return result;
}
示例15: ParseArgumentList
private NodeCollection<ArgumentNode> ParseArgumentList()
{
NodeCollection<ArgumentNode> list = new NodeCollection<ArgumentNode>();
if (curtok.ID == TokenID.RParen) return list;
while (true)
{
ArgumentNode arg = new ArgumentNode(curtok);
switch (curtok.ID)
{
case TokenID.Out:
Advance();
arg.IsOut = true;
break;
case TokenID.Ref:
Advance();
arg.IsRef = true;
break;
}
arg.Expression = ParseExpression();
list.Add(arg);
if (curtok.ID != TokenID.Comma) break;
Advance();
}
return list;
}