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; }
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"); }