Exemplo n.º 1
0
        public static byte[] CreateResponse(Func <int, Document> entityFactory, int itemsCount)
        {
            using var stream = new MemoryStream();
            using var writer = new Utf8JsonWriter(stream);

            writer.WriteStartObject();
            writer.WriteNumber("Count", itemsCount);

            writer.WritePropertyName("Items");
            writer.WriteStartArray();

            for (var i = 0; i < itemsCount; i++)
            {
                writer.WriteAttributesDictionary(entityFactory(i));
            }

            writer.WriteEndArray();

            writer.WriteNumber("ScannedCount", itemsCount);

            writer.WriteEndObject();
            writer.Flush();

            stream.Position = 0;
            return(stream.ToArray());
        }
Exemplo n.º 2
0
        public static byte[] CreateResponse(Document entity)
        {
            using var stream = new MemoryStream();
            using var writer = new Utf8JsonWriter(stream);

            writer.WriteStartObject();

            writer.WritePropertyName("Attributes");
            writer.WriteAttributesDictionary(entity);

            writer.WriteEndObject();
            writer.Flush();

            stream.Position = 0;
            return(stream.ToArray());
        }
 protected void WriteExclusiveStartKey(Utf8JsonWriter writer, IReadOnlyDictionary <string, AttributeValue> exclusiveStartKey)
 {
     writer.WritePropertyName("ExclusiveStartKey");
     writer.WriteAttributesDictionary(exclusiveStartKey);
 }