当前位置: 首页>>代码示例>>C#>>正文


C# DataNode.Expand方法代码示例

本文整理汇总了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;
        }
开发者ID:DMV-Jumbo,项目名称:NBTExplorer,代码行数:32,代码来源:JsonOperation.cs

示例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);
            }
        }
开发者ID:DMV-Jumbo,项目名称:NBTExplorer,代码行数:13,代码来源:PrintTreeOperation.cs

示例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);
                }
            }
        }
开发者ID:skonves,项目名称:NBTExplorer,代码行数:17,代码来源:DataNode.cs

示例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);
                }
            }
        }
开发者ID:Geemili,项目名称:NBTExplorer,代码行数:50,代码来源:SearchWorker.cs

示例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);
                }
            }
        }
开发者ID:johndpalm,项目名称:NBTExplorer,代码行数:80,代码来源:SearchWorker.cs


注:本文中的NBTExplorer.Model.DataNode.Expand方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。