本文整理汇总了C#中TreeNodeCollection.ToJson方法的典型用法代码示例。如果您正苦于以下问题:C# TreeNodeCollection.ToJson方法的具体用法?C# TreeNodeCollection.ToJson怎么用?C# TreeNodeCollection.ToJson使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TreeNodeCollection
的用法示例。
在下文中一共展示了TreeNodeCollection.ToJson方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessRequest
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/json";
// "node" will be a comma-separated list of nodes that are going to be deleted.
string node = context.Request["node"];
if (!string.IsNullOrEmpty(node))
{
string[] nodeIDsTemp = node.Split(',');
var nodeIDs = nodeIDsTemp.Select(s => Convert.ToInt32(s));
TreeNodeCollection treeNodes = new TreeNodeCollection();
foreach (int nodeID in nodeIDs)
{
ContentItem selectedItem = Context.Persister.Get(nodeID);
SiteTree tree = SiteTree.From(selectedItem, int.MaxValue);
TreeNodeBase treeNode = tree.Filter(items => items.Authorized(context.User, Context.SecurityManager, Operations.Read))
.ToTreeNode(false);
treeNodes.Add(treeNode);
}
string json = treeNodes.ToJson();
context.Response.Write(json);
context.Response.End();
}
}
示例2: ProcessRequest
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/json";
string nodeId = context.Request["node"];
if (!string.IsNullOrEmpty(nodeId))
{
TreeNodeCollection nodes = new TreeNodeCollection(false);
for (int i = 1; i < 6; i++)
{
AsyncTreeNode asyncNode = new AsyncTreeNode();
asyncNode.Text = nodeId + i;
asyncNode.NodeID = nodeId + i;
nodes.Add(asyncNode);
}
for (int i = 6; i < 11; i++)
{
TreeNode node = new TreeNode();
node.Text = nodeId + i;
node.NodeID = nodeId + i;
node.Leaf = true;
nodes.Add(node);
}
context.Response.Write(nodes.ToJson());
context.Response.End();
}
}
示例3: ProcessRequest
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/json";
// "node" will be a comma-separated list of nodes that are going to be deleted.
string node = context.Request["node"];
if (!string.IsNullOrEmpty(node))
{
string[] nodeIDsTemp = node.Split(',');
var nodeIDs = nodeIDsTemp.Select(s => Convert.ToInt32(s));
TreeNodeCollection treeNodes = new TreeNodeCollection();
foreach (int nodeID in nodeIDs)
{
ContentItem selectedItem = Context.Persister.Get(nodeID);
List<ContentItem> referrers = new List<ContentItem>();
AddReferencesRecursive(selectedItem, referrers);
foreach (ContentItem contentItem in referrers.Distinct(ci => ci.ID))
{
TreeNode treeNode = new TreeNode();
treeNode.Text = ((INode) contentItem).Contents;
treeNode.IconFile = contentItem.IconUrl;
treeNode.NodeID = contentItem.ID.ToString();
treeNode.Leaf = true;
treeNodes.Add(treeNode);
}
}
string json = treeNodes.ToJson();
context.Response.Write(json);
context.Response.End();
}
}
示例4: CarregaMenu
public string CarregaMenu()
{
int idPerfil = (int)Session["id_perfil"];
var listMenu = dbMenu.FindAll();
var listGrupoMenu = listMenu.Where(x => x.perfis.Contains(idPerfil.ToString())).GroupBy(x => x.grupo);
TreeNodeCollection nodes = new TreeNodeCollection(false);
int i = 0;
foreach (var m in listGrupoMenu)
{
i++;
TreeNode nodex = new TreeNode();
nodex.NodeID = i.ToString();
nodex.Text = m.Key;
nodex.Icon = Icon.Folder;
nodex.Expanded = true;
var subMenus = listMenu.Where(x => x.grupo == m.Key);
foreach(Entity.Menu me in subMenus)
{
if (me.perfis.Contains(idPerfil.ToString()))
{
i++;
TreeNode subNode = new TreeNode();
subNode.NodeID = i.ToString();
subNode.Text = me.titulo;
subNode.Listeners.Click.Handler = String.Format("addTab('{0}','{1}','{2}');", me.nomeTab, me.url, me.titulo);
subNode.Icon = (Icon)Enum.Parse(typeof(Icon),me.icon);
subNode.Leaf = true;
nodex.Nodes.Add(subNode);
}
}
nodes.Add(nodex);
}
return nodes.ToJson();
}
示例5: NodeLoad
public string NodeLoad(string gameId, string nodeId)
{
TreeNodeCollection nodes = new TreeNodeCollection();
if (!string.IsNullOrEmpty(nodeId))
{
if (nodeId == "tasks")
{
Game game = gameRepository.Get(Convert.ToInt32(gameId));
foreach(Task task in game.Tasks)
{
TreeNode treeNode = new TreeNode();
treeNode.Text = task.Name;
treeNode.NodeID = task.Id.ToString();
treeNode.Leaf = true;
nodes.Add(treeNode);
}
}
else if (nodeId == "bonuses")
{
Game game = gameRepository.Get(Convert.ToInt32(gameId));
foreach (BonusTask task in game.BonusTasks)
{
TreeNode treeNode = new TreeNode();
treeNode.Text = task.Name;
treeNode.NodeID = task.Id.ToString();
treeNode.Leaf = true;
nodes.Add(treeNode);
}
}
else if (nodeId == "teams")
{
Game game = gameRepository.Get(Convert.ToInt32(gameId));
foreach (Team team in game.Teams)
{
TreeNode treeNode = new TreeNode();
treeNode.Text = team.Name;
treeNode.NodeID = team.Id.ToString();
treeNode.Leaf = true;
nodes.Add(treeNode);
}
}
}
string result = nodes.ToJson();
return result;
}