本文整理汇总了C#中NBTExplorer.Model.DataNode.Expand方法的典型用法代码示例。如果您正苦于以下问题:C# DataNode.Expand方法的具体用法?C# DataNode.Expand怎么用?C# DataNode.Expand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NBTExplorer.Model.DataNode
的用法示例。
在下文中一共展示了DataNode.Expand方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Process
public override bool Process (DataNode dataNode, ConsoleOptions options)
{
if (options.Values.Count == 0)
return false;
string jsonPath = options.Values[0];
using (FileStream stream = File.OpenWrite(jsonPath)) {
using (StreamWriter writer = new StreamWriter(stream)) {
if (dataNode is TagDataNode) {
TagDataNode tagNode = dataNode as TagDataNode;
WriteNbtTag(writer, tagNode.Tag);
}
else if (dataNode is NbtFileDataNode) {
dataNode.Expand();
TagNodeCompound root = new TagNodeCompound();
foreach (DataNode child in dataNode.Nodes) {
TagDataNode childTagNode = child as TagDataNode;
if (childTagNode == null)
continue;
if (childTagNode.Tag != null)
root.Add(childTagNode.NodeName, childTagNode.Tag);
}
WriteNbtTag(writer, root);
}
}
}
return true;
}
示例2: PrintSubTree
private void PrintSubTree (DataNode dataNode, ConsoleOptions options, string indent, bool last)
{
Console.WriteLine(indent + " + " + TypePrinter.Print(dataNode, options.ShowTypes));
indent += last ? " " : " |";
int cnt = 0;
dataNode.Expand();
foreach (DataNode child in dataNode.Nodes) {
cnt++;
PrintSubTree(child, options, indent, cnt == dataNode.Nodes.Count);
}
}
示例3: RestoreExpandSet
protected void RestoreExpandSet(DataNode node, Dictionary<string, object> expandSet)
{
node.Expand();
foreach (DataNode child in node.Nodes) {
if (expandSet.ContainsKey(child.NodeName)) {
Dictionary<string, object> childDict = (Dictionary<string, object>)expandSet[child.NodeName];
if (childDict != null)
RestoreExpandSet(child, childDict);
}
else if (expandSet.ContainsKey(child.NodeDisplay)) {
Dictionary<string, object> childDict = (Dictionary<string, object>)expandSet[child.NodeDisplay];
if (childDict != null)
RestoreExpandSet(child, childDict);
}
}
}
示例4: FindNode
private IEnumerable<DataNode> FindNode(DataNode node)
{
lock (_lock) {
if (_cancel)
yield break;
}
if (node == null)
yield break;
bool searchExpanded = false;
if (!node.IsExpanded) {
node.Expand();
searchExpanded = true;
}
TagDataNode tagNode = node as TagDataNode;
if (tagNode != null) {
bool mName = _state.SearchName == null;
bool mValue = _state.SearchValue == null;
if (_state.SearchName != null) {
string tagName = node.NodeName;
if (tagName != null)
mName = tagName.Contains(_state.SearchName);
}
if (_state.SearchValue != null) {
string tagValue = node.NodeDisplay;
if (tagValue != null)
mValue = tagValue.Contains(_state.SearchValue);
}
if (mName && mValue) {
InvokeDiscoverCallback(node);
yield return node;
}
}
foreach (DataNode sub in node.Nodes) {
foreach (DataNode s in FindNode(sub))
yield return s;
}
if (searchExpanded) {
if (!node.IsModified) {
node.Collapse();
InvokeCollapseCallback(node);
}
}
}
示例5: FindNode
private IEnumerable<DataNode> FindNode(DataNode node)
{
lock (_lock) {
if (_cancel)
yield break;
}
if (node == null)
yield break;
bool searchExpanded = false;
if (!node.IsExpanded) {
node.Expand();
searchExpanded = true;
}
TagDataNode tagNode = node as TagDataNode;
if (tagNode != null) {
float currentSampleTime = (float)_progressWatch.Elapsed.TotalSeconds;
_progressTime += (currentSampleTime - _lastSampleTime);
_lastSampleTime = currentSampleTime;
if (_progressTime > _state.ProgressRate) {
InvokeProgressCallback(node);
_progressTime -= _state.ProgressRate;
}
if (_state.TestNode(tagNode)) {
InvokeDiscoverCallback(node);
if (_state.TerminateOnDiscover)
yield return node;
}
/*bool mName = _state.SearchName == null;
bool mValue = _state.SearchValue == null;
if (_state.SearchName != null) {
string tagName = node.NodeName;
if (tagName != null)
mName = tagName.Contains(_state.SearchName);
}
if (_state.SearchValue != null) {
string tagValue = node.NodeDisplay;
if (tagValue != null)
mValue = tagValue.Contains(_state.SearchValue);
}
if (mName && mValue) {
InvokeDiscoverCallback(node);
yield return node;
}*/
}
using (node.Nodes.Snapshot()) {
foreach (DataNode sub in node.Nodes) {
foreach (DataNode s in FindNode(sub))
yield return s;
}
}
/*IList<DataNode> nodeList = node.Nodes;
for (int i = 0; i < nodeList.Count; i++) {
int changeset = node.Nodes.ChangeCount;
foreach (DataNode s in FindNode(nodeList[i])) {
}
}
foreach (DataNode sub in node.Nodes) {
foreach (DataNode s in FindNode(sub))
yield return s;
}*/
if (searchExpanded) {
if (!node.IsModified) {
node.Collapse();
InvokeCollapseCallback(node);
}
}
}