public static RecordValue RecordFromFields(IEnumerable <NamedValue> fields) { var type = new RecordType(); foreach (var field in fields) { type = type.Add(new NamedFormulaType(field.Name, field.Value.IRContext.ResultType)); } return(new InMemoryRecordValue(IRContext.NotInSource(type), fields)); }
// Json objects parse to records. internal static RecordValue RecordFromJsonObject(JsonElement element) { Contract.Assert(element.ValueKind == JsonValueKind.Object); List <NamedValue> fields = new List <NamedValue>(); var type = new RecordType(); foreach (var pair in element.EnumerateObject()) { var name = pair.Name; JsonElement value = pair.Value; var paValue = FromJson(value); fields.Add(new NamedValue(name, paValue)); type = type.Add(new NamedFormulaType(name, paValue.IRContext.ResultType)); } return(new InMemoryRecordValue(IRContext.NotInSource(type), fields)); }