コード例 #1
0
ファイル: DroneApp.cs プロジェクト: juankakode/Drone
        private object GetTokenJsonValue(ParameterToken token, string type)
        {
            var result = null as object;

            switch (type)
            {
                case "auto":
                    result = this.GetTokenJsonValue(token, this.GetTokenJsonType(token));
                    break;

                case "obj":
                    result = JObject.Parse(token.Value);
                    break;

                case "list":
                    result = JArray.Parse(token.Value);
                    break;

                case "str":
                case "num":
                case "bool":
                    result = new JValue(token.Value);
                    break;

                default:
                    throw new InvalidOperationException("invalid type provided to set command");
            }

            return result;
        }
コード例 #2
0
ファイル: DroneApp.cs プロジェクト: juankakode/Drone
        private string GetTokenJsonType(ParameterToken token)
        {
            if (token.Type == ParameterTokenType.String)
                return "str";

            if (token.Type == ParameterTokenType.Json)
                return "obj";

            if (token.Type == ParameterTokenType.Symbol)
            {
                if (this.IsBool(token.Value))
                    return "bool";

                if (this.IsNumber(token.Value))
                    return "num";

                return "str";
            }

            throw new InvalidOperationException("unable to determine type for token");
        }