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


C# JsonValue.GetArray方法代码示例

本文整理汇总了C#中JsonValue.GetArray方法的典型用法代码示例。如果您正苦于以下问题:C# JsonValue.GetArray方法的具体用法?C# JsonValue.GetArray怎么用?C# JsonValue.GetArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JsonValue的用法示例。


在下文中一共展示了JsonValue.GetArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProcessBacktrace

        /// <summary>
        /// Handles backtrace response message.
        /// </summary>
        /// <param name="thread">Thread.</param>
        /// <param name="message">Message.</param>
        /// <returns>Array of stack frames.</returns>
        public void ProcessBacktrace(NodeThread thread, Dictionary<int, NodeModule> modules, JsonValue message, Action<NodeStackFrame[]> successHandler) {
            Utilities.ArgumentNotNull("thread", thread);
            Utilities.ArgumentNotNull("message", message);

            // Extract scripts (if not provided)
            if (modules == null) {
                JsonArray refs = message.GetArray("refs");
                modules = GetScripts(thread.Process, refs);
            }

            // Extract frames
            JsonValue body = message["body"];
            JsonArray frames = body.GetArray("frames");
            if (frames == null) {
                if (successHandler != null) {
                    successHandler(new NodeStackFrame[] { });
                }
                return;
            }

            var stackFrames = new List<NodeStackFrame>(frames.Count);

            for (int i = 0; i < frames.Count; i++) {
                JsonValue frame = frames[i];

                // Create stack frame
                string name = GetFrameName(frame);
                var moduleId = frame["func"].GetValue<int>("scriptId");
                NodeModule module;
                if (!modules.TryGetValue(moduleId, out module)) {
                    module = _unknownModule;
                }

                int line = frame.GetValue<int>("line") + 1;
                var stackFrameId = frame.GetValue<int>("index");

                var stackFrame = new NodeStackFrame(thread, module, name, line, line, line, stackFrameId);

                // Locals
                JsonArray variables = frame.GetArray("locals");
                List<NodeEvaluationResult> locals = GetVariables(stackFrame, variables);

                // Arguments
                variables = frame.GetArray("arguments");
                List<NodeEvaluationResult> parameters = GetVariables(stackFrame, variables);

                stackFrame.Locals = locals;
                stackFrame.Parameters = parameters;

                stackFrames.Add(stackFrame);
            }

            if (successHandler != null) {
                successHandler(stackFrames.ToArray());
            }
        }
开发者ID:lioaphy,项目名称:nodejstools,代码行数:62,代码来源:NodeResponseHandler.cs

示例2: ProcessLookup

        /// <summary>
        /// Handles lookup response message.
        /// </summary>
        /// <param name="parent">Parent variable.</param>
        /// <param name="message">Message.</param>
        /// <returns>Array of evaluation results.</returns>
        public NodeEvaluationResult[] ProcessLookup(NodeEvaluationResult parent, JsonValue message) {
            Utilities.ArgumentNotNull("parent", parent);
            Utilities.ArgumentNotNull("message", message);

            // Retrieve references
            JsonArray refs = message.GetArray("refs");
            var references = new Dictionary<int, JsonValue>(refs.Count);
            for (int i = 0; i < refs.Count; i++) {
                JsonValue reference = refs[i];
                var id = reference.GetValue<int>("handle");
                references.Add(id, reference);
            }

            // Retrieve properties
            JsonValue body = message["body"];
            string handle = parent.Handle.ToString(CultureInfo.InvariantCulture);
            JsonValue objectData = body[handle];
            var properties = new List<NodeEvaluationResult>();

            JsonArray props = objectData.GetArray("properties");
            if (props != null) {
                for (int i = 0; i < props.Count; i++) {
                    JsonValue property = props[i];
                    var variableProvider = new NodeLookupVariable(parent, property, references);
                    NodeEvaluationResult result = _evaluationResultFactory.Create(variableProvider);
                    properties.Add(result);
                }
            }

            // Try to get prototype
            JsonValue prototype = objectData["protoObject"];
            if (prototype != null) {
                var variableProvider = new NodePrototypeVariable(parent, prototype, references);
                NodeEvaluationResult result = _evaluationResultFactory.Create(variableProvider);
                properties.Add(result);
            }

            return properties.ToArray();
        }
开发者ID:lioaphy,项目名称:nodejstools,代码行数:45,代码来源:NodeResponseHandler.cs


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