/// <summary> /// Creates an object literal from a list of bindings. /// </summary> public static ObjectLiteral Create(IReadOnlyList <Binding> bindings, LineInfo location, AbsolutePath path) { Contract.Requires(bindings != null); var namedValues = new List <NamedValue>(bindings.Count); foreach (var b in bindings.AsStructEnumerable()) { namedValues.Add(NamedValue.Create(b)); } return(Create(namedValues, location, path)); }
/// <summary> /// Creates an object literal from the stream. /// </summary> public static ObjectLiteral Create(DeserializationContext context, LineInfo location) { var reader = context.Reader; var path = reader.ReadAbsolutePath(); var count = reader.ReadInt32Compact(); var namedValues = new List <NamedValue>(count); for (int i = 0; i < count; i++) { var name = reader.ReadStringId(); bool isNode = reader.ReadBoolean(); object body = isNode ? Read(context) : ConstExpressionSerializer.ReadConstValue(reader); namedValues.Add(NamedValue.Create(new Binding(name, body, location))); } return(Create(namedValues, location, path)); }