本文整理汇总了C#中Newtonsoft.Json.JsonWriter.EndObject方法的典型用法代码示例。如果您正苦于以下问题:C# JsonWriter.EndObject方法的具体用法?C# JsonWriter.EndObject怎么用?C# JsonWriter.EndObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Newtonsoft.Json.JsonWriter
的用法示例。
在下文中一共展示了JsonWriter.EndObject方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
var push = value as PushNotification;
if (push == null)
{
writer.WriteNull();
return;
}
writer.StartObject();
// Write push type
if (string.IsNullOrWhiteSpace(push.Query) == false)
writer.WriteProperty("query", push.Query);
else if( push.Channels.Count() > 0 )
writer.WriteArray("channels", push.Channels);
else if( push.DeviceIds.Count() > 0 )
writer.WriteArray("deviceids", push.DeviceIds);
else
writer.WriteProperty("broadcast", true);
// Write data
WriteData(writer, push);
// Write platform options
WritePlatformOptions(writer, push.PlatformOptions);
writer.EndObject();
}
示例2: WriteTileOptions
private void WriteTileOptions(JsonWriter writer, TileNotification option)
{
writer.StartObject();
writer.WriteProperty("notificationtype", "tile");
WriteTile(writer, "wp8", option.WP8Tile);
WriteTile(writer, "wp75", option.WP75Tile);
WriteTile(writer, "wp7", option.WP7Tile);
writer.EndObject();
}
示例3: WritePlatformOptions
private void WritePlatformOptions(JsonWriter writer, PlatformOptions options)
{
if (options == null || options.IsEmpty == true ) return;
writer.WriteProperty("platformoptions");
writer.StartObject();
if (options.iOS != null)
WriteIosOptions(writer, options.iOS);
if (options.Android != null)
WriteAndroidOptions(writer, options.Android);
if (options.WindowsPhone != null)
WriteWpOptions(writer, options.WindowsPhone);
writer.EndObject();
}
示例4: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
Entity entity = value as Entity;
if (entity == null)
{
writer.WriteNull();
return;
}
writer.StartObject();
writer
// Write id
.WithWriter(w =>
{
if (string.IsNullOrWhiteSpace(entity.Id) == false)
w.WriteProperty("__id", entity.Id);
})
// Write created by
.WriteProperty("__createdby", entity.CreatedBy)
// Write properties
.WithWriter(w =>
{
foreach (var property in entity.Properties)
w.WriteProperty(property.Key, property.Value);
})
.WithWriter( w => WriteJson(entity, w, serializer) )
.WithWriter(w =>
{
var attr = entity.Attributes.ToArray();
if (attr.Length > 0)
{
w.WriteProperty("__attributes")
.StartObject();
// Write attributes
for (int i = 0; i < attr.Length; i++)
w.WriteProperty(attr[i].Key, attr[i].Value);
w.EndObject();
}
})
.WithWriter(w =>
{
if (entity.Tags.Count() > 0)
w.WriteArray("__tags", entity.Tags);
});
writer.EndObject();
}
示例5: WriteData
private void WriteData(JsonWriter writer, PushNotification push)
{
writer.WritePropertyName("data");
writer.StartObject();
writer
.WriteProperty("alert", push.Alert)
.WriteProperty("badge", push.Badge, true);
foreach (var key in push.Data.Keys)
{
if (key.Equals("alert", StringComparison.OrdinalIgnoreCase) == true ||
key.Equals("badge", StringComparison.OrdinalIgnoreCase) == true)
continue;
writer.WriteProperty(key, push.Data[key]);
}
writer.EndObject();
}
示例6: WriteAttributes
private static void WriteAttributes(JsonWriter writer, Entity entity, JsonSerializer serializer)
{
var attr = entity.Attributes.ToArray();
if (attr.Length > 0)
{
writer.WriteProperty("__attributes");
writer.StartObject();
// Write attributes
for (int i = 0; i < attr.Length; i++)
writer.WriteProperty(attr[i].Key, attr[i].Value);
writer.EndObject();
}
}
示例7: WriteEndpoint
private void WriteEndpoint(string property, JsonWriter writer, Endpoint endpoint)
{
writer
.WriteProperty(property)
.StartObject()
.WriteProperty("label", endpoint.Label);
if (endpoint.HasBatchReference == true)
writer.WriteProperty("name", endpoint.ObjectReference.ObjectHandle);
else if (endpoint.CreateEndpoint == false)
writer.WriteProperty("objectid", endpoint.ObjectId);
else
writer
.WriteProperty("object")
.WithWriter(w => WriteObject(w, endpoint.Content));
writer.EndObject();
}