public static void Read(string source, KeyboardAdapter adapter) { var dict = new Json.JsonParser(source).Parse() as Dictionary <string, object>; if (dict != null) { foreach (var kv in dict) { var lst = kv.Value as List <object>; if (lst != null) { foreach (var o in lst) { var str = o as string; if (str != null) { adapter.RegisterInput((Identifier)kv.Key, str); } } } else { var str = kv.Value as string; if (str != null) { adapter.RegisterInput((Identifier)kv.Key, str); } } } } }
private void LoadJsonSources(IBSharpContext context) { var jsonparser = new Json.JsonParser(); foreach (var file in Directory.GetFiles(Project.GetRootDirectory(), "*.bxls.json", SearchOption.AllDirectories)) { try { var xml = jsonparser.ParseXml(File.ReadAllText(file)); ConvertToBSharpSourceXml(file, xml); Project.Sources.Add(xml); Project.Log.Debug("add src from " + file); } catch (Exception ex) { context.RegisterError(BSharpErrors.Generic(ex)); Project.Log.Fatal("cannot load src from " + file + " : " + ex.Message); } } }
private void LoadJsonSources(IBSharpContext context) { var jsonparser = new Json.JsonParser(); foreach (var file in Directory.GetFiles(Project.GetRootDirectory(), "*.bxls.json", SearchOption.AllDirectories)) { try { var xml = jsonparser.ParseXml(File.ReadAllText(file)); ConvertToBSharpSourceXml(file, xml); Project.Sources.Add(xml); Project.Log.Debug("add src from " + file); } catch (Exception ex) { context.RegisterError(BSharpErrors.Generic(ex)); Project.Log.Fatal("cannot load src from " + file + " : " + ex.Message); } } }
public Task Read() { var ser = new Json.JsonParser(File.ReadAllText(FileName)) { SkipNulls = true }; var dict = ser.Parse() as Dictionary <string, object>; var task = new Task { Name = GetParamStr(dict, "name", true) }; task.DefaultProperties = ReadProperties(dict); var vars = GetParam(dict, "variables") as Dictionary <string, object>; if (vars != null) { foreach (var kv in vars) { task.Variables.Add(kv.Key, (kv.Value == null ? "" : kv.Value).ToString()); } } var steps = GetParam(dict, "steps", true) as List <object>; if (steps != null) { foreach (var o in steps) { var stepDic = o as Dictionary <string, object>; if (stepDic != null) { task.Steps.Add(CreateStep(stepDic, task)); } } } return(task); }