public static string Setup( string inputJson, List <int> cpus, string solver, string caseType, List <string> boundaryConditions, string iterations, List <List <double> > numberOfAngles, string overrides = null, List <string> files = null ) { var inputData = new Inputs().FromJson(inputJson); // Merge the list of dictionaries to one big dict var bcs_ = new List <Dictionary <string, object> >(); foreach (var bc in boundaryConditions) { bcs_.Add(JsonConvert.DeserializeObject <Dictionary <string, object> >(bc)); } var bcs = bcs_.SelectMany(x => x).GroupBy(d => d.Key).ToDictionary(x => x.Key, y => y.First().Value); // Convert iterations from json to dict var _iterations = JsonConvert.DeserializeObject <Dictionary <string, int> >(iterations); // Convert overrides to dict Dictionary <string, object> _overrides = null; if (overrides != null) { _overrides = JsonConvert.DeserializeObject <Dictionary <string, object> >(overrides); } // Convert overrides to dict var _files = new List <Dictionary <string, object> >(); if (files != null) { _files.AddRange(files.Select(file => JsonConvert.DeserializeObject <Dictionary <string, object> >(file))); } var solution = new types.CFDSolution { CPUs = cpus, Solver = solver, CaseType = caseType, BoundaryConditions = bcs, Iterations = _iterations, Angles = caseType == "VirtualWindTunnel"? GetAngleListFromNumber(numberOfAngles, _overrides): null, Overrides = _overrides, Files = _files }; inputData.CFDSolution = solution; return(inputData.ToJson()); }
public static Dictionary <string, object> Setup( string inputJson, List <int> cpus, string solver, string caseType, List <string> boundaryConditions, string iterations, int numberOfAngles, string overrides = null ) { var inputData = new Inputs().FromJson(inputJson); // Merge the list of dictionaries to one big dict var bcs_ = new List <Dictionary <string, object> >(); foreach (string bc in boundaryConditions) { bcs_.Add(JsonConvert.DeserializeObject <Dictionary <string, object> >(bc)); } Dictionary <string, object> bcs = bcs_.SelectMany(x => x).GroupBy(d => d.Key).ToDictionary(x => x.Key, y => y.First().Value); // Convert iterations from json to dict var iterations_ = JsonConvert.DeserializeObject <Dictionary <string, int> >(iterations); // Convert overrides to dict Dictionary <string, object> overrides_ = null; if (overrides != null) { overrides_ = JsonConvert.DeserializeObject <Dictionary <string, object> >(overrides); } var solution = new types.CFDSolution { CPUs = cpus, Solver = solver, CaseType = caseType, BoundaryConditions = bcs, Iterations = iterations_, Angles = GetAngleListFromNumber(numberOfAngles), Overrides = overrides_ }; inputData.CFDSolution = solution; var output = inputData.ToJson(); return(new Dictionary <string, object> { { "out", output } }); }