private static SkryptObject Input(SkryptEngine engine, SkryptObject self, Arguments arguments) { if (arguments.Length == 1) { Console.WriteLine(arguments[0]); } string fullString = ""; string line; while (!String.IsNullOrWhiteSpace(line = Console.ReadLine())) { fullString += line; } return(engine.CreateString(fullString)); }
public static SkryptObject ToJson(SkryptEngine engine, SkryptObject self, Arguments arguments) { var value = arguments[0]; var indented = arguments.Length > 1 ? arguments.GetAs <BooleanInstance>(1): false; var writeFunctions = arguments.Length > 2 ? arguments.GetAs <BooleanInstance>(2) : false; var jsonString = JsonConvert.SerializeObject(value, indented ? Formatting.Indented : Formatting.None, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Serialize, Converters = new JsonConverter[] { new SkryptNumberJsonConverter(), new SkryptStringJsonConverter(), new SkryptBooleanJsonConverter(), new SkryptArrayJsonConverter(), new SkryptObjectJsonConverter(writeFunctions) } }); return(engine.CreateString(jsonString)); }
public static StringInstance ToStringInstance(SkryptEngine engine, string val) => engine.CreateString(val);