本文整理汇总了C#中Raven.Imports.Newtonsoft.Json.JsonWriter.WriteEndArray方法的典型用法代码示例。如果您正苦于以下问题:C# JsonWriter.WriteEndArray方法的具体用法?C# JsonWriter.WriteEndArray怎么用?C# JsonWriter.WriteEndArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Raven.Imports.Newtonsoft.Json.JsonWriter
的用法示例。
在下文中一共展示了JsonWriter.WriteEndArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteJsonCoordinates
private static void WriteJsonCoordinates(JsonWriter writer, IEnumerable<Coordinate> coordinates, JsonSerializer serializer)
{
writer.WriteStartArray();
foreach (Coordinate coordinate in coordinates)
WriteJsonCoordinate(writer, coordinate, serializer);
writer.WriteEndArray();
}
示例2: WriteJsonCoordinatesEnumerable2
private static void WriteJsonCoordinatesEnumerable2(JsonWriter writer, List<List<Coordinate[]>> coordinates, JsonSerializer serializer)
{
writer.WriteStartArray();
foreach (List<Coordinate[]> coordinate in coordinates)
WriteJsonCoordinatesEnumerable(writer, coordinate, serializer);
writer.WriteEndArray();
}
示例3: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
var collection = (NameValueCollection)value;
writer.WriteStartObject();
foreach (var key in collection.AllKeys)
{
writer.WritePropertyName(key);
var values = collection.GetValues(key);
if (values == null)
{
writer.WriteNull();
continue;
}
if (values.Length == 1)
{
writer.WriteValue(values[0]);
}
else
{
writer.WriteStartArray();
foreach (var item in values)
{
writer.WriteValue(item);
}
writer.WriteEndArray();
}
}
writer.WriteEndObject();
}
示例4: WriteArray
private void WriteArray(JsonWriter writer, object value) {
writer.WriteStartArray();
var array = value as IEnumerable<object>;
foreach (var o in array) {
this.WriteValue(writer, o);
}
writer.WriteEndArray();
}
示例5: WriteJson
/// <summary>
/// Writes the JSON representation of the object.
/// </summary>
/// <remarks>This will enumerate the Linq-To-Entities query before serializing it to json array</remarks>
/// <param name="writer">The <see cref="JsonWriter"/> to write to.</param>
/// <param name="value">The value.</param>
/// <param name="serializer">The calling serializer.</param>
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
var enumerable = (IEnumerable) value;
writer.WriteStartArray();
foreach(var item in enumerable)
writer.WriteValue(item);
writer.WriteEndArray();
}
示例6: WriteJsonCoordinate
private static void WriteJsonCoordinate(JsonWriter writer, Coordinate coordinate, JsonSerializer serializer)
{
writer.WriteStartArray();
writer.WriteValue(coordinate.X);
writer.WriteValue(coordinate.Y);
if (!Double.IsNaN(coordinate.Z))
writer.WriteValue(coordinate.Z);
writer.WriteEndArray();
}
示例7: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
Envelope envelope = value as Envelope;
if (envelope == null) return;
writer.WritePropertyName("bbox");
writer.WriteStartArray();
writer.WriteValue(envelope.MinX);
writer.WriteValue(envelope.MinY);
writer.WriteValue(envelope.MaxX);
writer.WriteValue(envelope.MaxY);
writer.WriteEndArray();
}
示例8: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
writer.WriteStartArray();
foreach (object item in (IEnumerable) value)
{
writer.WriteStartObject();
writer.WritePropertyName("CrlType");
writer.WriteValue(item.GetType().AssemblyQualifiedName);
writer.WritePropertyName("Value");
serializer.Serialize(writer, item);
writer.WriteEndObject();
}
writer.WriteEndArray();
}
示例9: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
var coordinate = value as Coordinate;
if (coordinate == null)
{
writer.WriteNull();
return;
}
writer.WriteStartArray();
writer.WriteValue(coordinate.Longitude);
writer.WriteValue(coordinate.Latitude);
if (coordinate.Is3D || coordinate.IsMeasured)
writer.WriteValue(((Is3D)coordinate).Elevation);
if (coordinate.IsMeasured)
writer.WriteValue(((IsMeasured)coordinate).Measure);
writer.WriteEndArray();
}
示例10: WriteItemsFromDb
private static void WriteItemsFromDb(JsonWriter jsonWriter, string name, Func<int, RavenJArray> getBatchOfItems)
{
jsonWriter.WritePropertyName(name);
jsonWriter.WriteStartArray();
var totalCount = 0;
while (true)
{
var array = getBatchOfItems(totalCount);
if (array.Length == 0)
{
break;
}
totalCount += array.Length;
foreach (var item in array)
{
item.WriteTo(jsonWriter);
}
}
jsonWriter.WriteEndArray();
}
示例11: WriteRank
/// <summary>
/// Write a rank of an array in Json format
/// </summary>
/// <param name="writer">JsonWriter in use</param>
/// <param name="serializer">JsonSerializer in use</param>
/// <param name="array">Array to be written</param>
/// <param name="currentRank">Current rank "depth"</param>
/// <param name="assignFromIndexList">List of indexes currently being used to read from the array</param>
private void WriteRank(JsonWriter writer, JsonSerializer serializer, Array array, int currentRank, int[] assignFromIndexList)
{
writer.WriteStartArray();
var lb = array.GetLowerBound(currentRank);
var ub = array.GetUpperBound(currentRank);
// Create a new indices list (one bigger than passed in) and fill with existing values
var myAssignFromIndex = assignFromIndexList.GetUpperBound(0) + 1;
var myAssignFromIndexList = new int[myAssignFromIndex + 1];
Array.Copy(assignFromIndexList, myAssignFromIndexList, assignFromIndexList.Length);
for (var i = lb; i <= ub; i++)
{
// set current index of this current rank
myAssignFromIndexList[myAssignFromIndex] = i;
if (currentRank < array.Rank - 1) // There are still more ranks, process them
WriteRank(writer, serializer, array, currentRank + 1, myAssignFromIndexList);
else // This is the "bottom" rank, write out values
serializer.Serialize(writer, array.GetValue(myAssignFromIndexList));
}
writer.WriteEndArray();
}
示例12: WriteGeometries
private static void WriteGeometries(JsonWriter writer, IEnumerable<IGeometry> geometries, JsonSerializer serializer)
{
writer.WriteStartArray();
foreach (IGeometry geometry in geometries)
serializer.Serialize(writer, geometry);
writer.WriteEndArray();
}
示例13: TryWriteGeo
public bool TryWriteGeo(JsonWriter writer, object value, JsonSerializer serializer)
{
var route = value as Route;
if (route != null)
{
writer.WriteStartObject();
writer.WritePropertyName("__geo");
writer.WriteStartObject();
writer.WritePropertyName("type");
writer.WriteValue("Route");
if (route.Metadata.Count > 0)
{
writer.WritePropertyName("metadata");
serializer.Serialize(writer, route.Metadata);
}
writer.WriteEndObject();
writer.WritePropertyName("type");
writer.WriteValue(Enum.GetName(typeof(ObjectType), ObjectType.LineString));
writer.WritePropertyName("coordinates");
WriteJsonCoordinates(writer, _shapeConverter.FromLineString(route.ToLineString()));
writer.WriteEndObject();
return true;
}
var track = value as Track;
if (track != null)
{
writer.WriteStartObject();
writer.WritePropertyName("__geo");
writer.WriteStartObject();
writer.WritePropertyName("type");
writer.WriteValue("Track");
if (track.Metadata.Count > 0)
{
writer.WritePropertyName("metadata");
serializer.Serialize(writer, track.Metadata);
}
writer.WritePropertyName("times");
writer.WriteStartArray();
foreach (var segment in track.Segments)
{
writer.WriteStartArray();
foreach (var fix in segment.Fixes)
writer.WriteValue(fix.TimeUtc);
writer.WriteEndArray();
}
writer.WriteEndArray();
writer.WriteEndObject();
writer.WritePropertyName("type");
writer.WriteValue(Enum.GetName(typeof(ObjectType), ObjectType.LineString));
writer.WritePropertyName("coordinates");
WriteJsonCoordinates(writer, _shapeConverter.FromLineString(track.ToLineString()));
writer.WriteEndObject();
return true;
}
return false;
}
示例14: TryWriteGeometryCollection
public bool TryWriteGeometryCollection(JsonWriter writer, object value, JsonSerializer serializer)
{
if (!_shapeConverter.CanConvert(ObjectType.GeometryCollection))
return false;
ObjectType geomType = _shapeConverter.GetObjectType(value);
if (geomType != ObjectType.GeometryCollection)
return false;
writer.WriteStartObject();
writer.WritePropertyName("type");
writer.WriteValue(Enum.GetName(typeof(ObjectType), geomType));
writer.WritePropertyName("geometries");
writer.WriteStartArray();
foreach (var geometry in _shapeConverter.FromGeometryCollection(value))
serializer.Serialize(writer, geometry);
writer.WriteEndArray();
writer.WriteEndObject();
return true;
}
示例15: WriteJsonCoordinatesEnumerable2
protected static void WriteJsonCoordinatesEnumerable2(JsonWriter writer, CoordinateInfo[][][] coordinates)
{
writer.WriteStartArray();
foreach (var coordinate in coordinates)
WriteJsonCoordinatesEnumerable(writer, coordinate);
writer.WriteEndArray();
}