Ejemplo n.º 1
0
        public IEnumerable <Variable> GetVariablesByName(IEnumerable <string> names, EVariableNamespace scope = EVariableNamespace.MissionNamespace)
        {
            var command = new asapJson.JsonNode(new Dictionary <string, asapJson.JsonNode>());

            command.GetValue_Object()["command"] = new asapJson.JsonNode((int)ESendCommands.GetVariable);
            var data = command.GetValue_Object()["data"];

            data.GetValue_Object()["name"]  = new asapJson.JsonNode(new List <asapJson.JsonNode>(names.Select(name => new asapJson.JsonNode(name))));
            data.GetValue_Object()["scope"] = new asapJson.JsonNode((int)scope);
            this.WriteMessage(command);

            //have to wait for response now. which will be command 3

            throw new NotImplementedException();
            //command should be the returned packet
            var variables = command.GetValue_Object()["data"];

            foreach (var variable in variables.GetValue_Array())
            {
                var name  = variable.GetValue_Object()["name"].GetValue_String();
                var type  = variable.GetValue_Object()["type"].GetValue_String();
                var value = "";
                if (type != "void")
                {
                    value = variable.GetValue_Object()["value"].GetValue_String();
                    var ns = (EVariableNamespace)variable.GetValue_Object()["ns"].GetValue_Number();//Namespace the variable comes from
                }
                yield return(new Variable()
                {
                    Name = name, Value = value, VariableType = Variable.ValueType.Parse(type)
                });
            }
        }
Ejemplo n.º 2
0
 public async Task <IEnumerable <Variable> > GetVariables(EVariableNamespace scope = EVariableNamespace.All, params string[] names)
 {
     if (!this.IsDebuggerAttached)
     {
         return(new Variable[0]);
     }
     return(await this.DebuggerInstance.GetVariablesAsync(scope, names));
 }
Ejemplo n.º 3
0
        public IEnumerable <Variable> GetVariables(EVariableNamespace scope, params string[] names)
        {
            var command = new asapJson.JsonNode(new Dictionary <string, asapJson.JsonNode>());

            command.GetValue_Object()["command"] = new asapJson.JsonNode((int)ESendCommands.GetVariable);
            var data = command.GetValue_Object()["data"] = new asapJson.JsonNode(new Dictionary <string, asapJson.JsonNode>());

            data.GetValue_Object()["name"]  = new asapJson.JsonNode(names.Select(name => new asapJson.JsonNode(name)));
            data.GetValue_Object()["scope"] = new asapJson.JsonNode((int)scope);
            this.WriteMessage(command);


            var response = this.ReadMessage((node) => (int)(node.GetValue_Object()["command"].GetValue_Number()) == (int)ERecvCommands.VariablesList);

            var variables = response.GetValue_Object()["data"];

            if (variables.GetValueType() == JsonNode.EJType.Array) //Might be null if no variables found
            {
                foreach (var variable in variables.GetValue_Array())
                {
                    var name  = variable.GetValue_Object()["name"].GetValue_String();
                    var type  = variable.GetValue_Object()["type"].GetValue_String();
                    var value = "";
                    switch (type)
                    {
                    case "void":
                        yield return(new Variable()
                        {
                            Name = name, Value = value, VariableType = Variable.ValueType.ANY
                        });

                        break;

                    case "array":
                    {
                        value = VariableArrayToString(variable.GetValue_Object()["value"]);
                        var ns = (EVariableNamespace)variable.GetValue_Object()["ns"].GetValue_Number();    //Namespace the variable comes from
                        yield return(new Variable()
                            {
                                Name = name, Value = value, VariableType = Variable.ValueType.ARRAY, Namespace = ns
                            });
                    }
                    break;

                    default:
                    {
                        value = variable.GetValue_Object()["value"].GetValue_String();
                        var ns = (EVariableNamespace)variable.GetValue_Object()["ns"].GetValue_Number();    //Namespace the variable comes from
                        yield return(new Variable()
                            {
                                Name = name, Value = value, VariableType = Variable.ValueType.Parse(type), Namespace = ns
                            });
                    }
                    break;
                    }
                }
            }
        }
Ejemplo n.º 4
0
 public static async Task <IEnumerable <Variable> > GetVariablesAsync(this IDebugger dbgr, EVariableNamespace scope = EVariableNamespace.All, params string[] names)
 {
     return(await Task.Run(() => dbgr.GetVariables(scope, names)));
 }
Ejemplo n.º 5
0
        public IEnumerable <Variable> GetVariables(EVariableNamespace scope, params string[] names)
        {
            var node = new Newtonsoft.Json.Linq.JObject
            {
                { "command", (int)ESendCommands.GetVariable },
                { "data", new Newtonsoft.Json.Linq.JObject {
                      { "name", new Newtonsoft.Json.Linq.JArray(names.Select((name) => new Newtonsoft.Json.Linq.JValue(name))) },
                      { "scope", 0 }
                  } }
            };

            switch (scope)
            {
            case EVariableNamespace.All:
                node["data"]["scope"] = (int)EVariableScope.All;
                break;

            case EVariableNamespace.Callstack:
                node["data"]["scope"] = (int)EVariableScope.Callstack;
                break;

            case EVariableNamespace.LocalEvaluator:
                node["data"]["scope"] = (int)EVariableScope.Local;
                break;

            case EVariableNamespace.MissionNamespace:
                node["data"]["scope"] = (int)EVariableScope.MissionNamespace;
                break;

            case EVariableNamespace.ParsingNamespace:
                node["data"]["scope"] = (int)EVariableScope.ParsingNamespace;
                break;

            case EVariableNamespace.ProfileNamespace:
                node["data"]["scope"] = (int)EVariableScope.ProfileNamespace;
                break;

            case EVariableNamespace.UiNamespace:
                node["data"]["scope"] = (int)EVariableScope.UiNamespace;
                break;
            }
            this.WriteMessage(node);
            var response = this.ReadMessage((n) => n.command == (int)ERecvCommands.VariableReturn);

            foreach (var variable in response.data)
            {
                string name  = variable.name;
                string type  = variable.type;
                var    value = "";
                switch (type)
                {
                case "void":
                    yield return(new Variable()
                    {
                        Name = name, Value = value, VariableType = Variable.ValueType.ANY
                    });

                    break;

                case "array":
                {
                    value = VariableArrayToString(variable.value);
                    var ns = (EVariableNamespace)variable.ns;        //Namespace the variable comes from
                    yield return(new Variable()
                        {
                            Name = name, Value = value, VariableType = Variable.ValueType.ARRAY, Namespace = ns
                        });
                }
                break;

                default:
                {
                    value = variable.value;
                    var ns = (EVariableNamespace)variable.ns;        //Namespace the variable comes from
                    yield return(new Variable()
                        {
                            Name = name, Value = value, VariableType = Variable.ValueType.Parse(type), Namespace = ns
                        });
                }
                break;
                }
            }
        }