本文整理汇总了C#中Newtonsoft.Json.JsonWriter.WriteProperty方法的典型用法代码示例。如果您正苦于以下问题:C# JsonWriter.WriteProperty方法的具体用法?C# JsonWriter.WriteProperty怎么用?C# JsonWriter.WriteProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Newtonsoft.Json.JsonWriter
的用法示例。
在下文中一共展示了JsonWriter.WriteProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: WriteJson
public override void WriteJson(JsonWriter writer)
{
writer.WriteStartObject();
writer.WriteProperty("mod", Module);
writer.WriteProperty("fun", Function);
writer.WriteEndObject();
}
示例3: WriteJson
// Writes JSON representaion of the method to the specified JsonWriter.
// Used to generate Ext.Direct API
internal void WriteJson(JsonWriter jsonWriter)
{
jsonWriter.WriteStartObject();
jsonWriter.WriteProperty("name", this.Name);
jsonWriter.WriteProperty("len", this.Len);
if (this.IsFormHandler) {
jsonWriter.WriteProperty("formHandler", true);
}
jsonWriter.WriteEndObject();
}
示例4: WriteFieldValueFactor
private bool WriteFieldValueFactor(JsonWriter writer, IFieldValueFactorFunction value, JsonSerializer serializer)
{
if (value == null) return false;
writer.WritePropertyName("field_value_factor");
writer.WriteStartObject();
{
writer.WriteProperty(serializer, "field", value.Field);
writer.WriteProperty(serializer, "factor", value.Factor);
writer.WriteProperty(serializer, "missing", value.Missing);
writer.WriteProperty(serializer, "modifier", value.Modifier);
}
writer.WriteEndObject();
return true;
}
示例5: WriteJson
protected override void WriteJson(Entity entity, JsonWriter writer, JsonSerializer serializer)
{
var conn = entity as Connection;
if (conn == null)
return;
// Write endpoint A
if (conn.CreateEndpointA == false)
{
writer
.WriteProperty("__endpointa")
.StartObject()
.WriteProperty("label", conn.EndpointA.Label)
.WriteProperty("articleid", conn.EndpointA.ArticleId)
.EndObject();
}
else
{
writer
.WriteProperty("__endpointa")
.StartObject()
.WriteProperty("label", conn.EndpointA.Label)
.WriteProperty("article")
.WithWriter( w => WriteArticle(w, conn.EndpointA.Content) )
.EndObject();
}
// Write endpoint B
if (conn.CreateEndpointB == false)
{
writer
.WriteProperty("__endpointb")
.StartObject()
.WriteProperty("label", conn.EndpointB.Label)
.WriteProperty("articleid", conn.EndpointB.ArticleId)
.EndObject();
}
else
{
writer
.WriteProperty("__endpointb")
.StartObject()
.WriteProperty("label", conn.EndpointB.Label)
.WriteProperty("article")
.WithWriter(w => WriteArticle(w, conn.EndpointB.Content))
.EndObject();
}
}
示例6: WriteJson
public void WriteJson(JsonWriter writer) {
writer.WriteStartObject();
writer.WriteProperty("name", Name);
if (Params != null) {
writer.WriteProperty("params", Params);
} else {
writer.WriteProperty("len", Len);
}
if (IsFormHandler) {
writer.WriteProperty("formHandler", true);
}
writer.WriteEndObject();
}
示例7: Serialize
public void Serialize(JsonWriter writer, object obj, JsonSerializer serializer)
{
if (obj == null) return;
var issue = (Issue) obj;
writer.WriteStartObject();
writer.WriteValue(RedmineKeys.ISSUE);
writer.WriteProperty(RedmineKeys.SUBJECT, issue.Subject);
writer.WriteProperty(RedmineKeys.DESCRIPTION, issue.Description);
writer.WriteProperty(RedmineKeys.NOTES, issue.Notes);
if (issue.Id != 0)
{
writer.WriteProperty(RedmineKeys.PRIVATE_NOTES, issue.PrivateNotes);
}
writer.WriteProperty(RedmineKeys.IS_PRIVATE, issue.IsPrivate);
writer.WriteIdIfNotNull(RedmineKeys.PROJECT_ID, issue.Project);
writer.WriteIdIfNotNull(RedmineKeys.PRIORITY_ID, issue.Priority);
writer.WriteIdIfNotNull(RedmineKeys.STATUS_ID, issue.Status);
writer.WriteIdIfNotNull(RedmineKeys.CATEGORY_ID, issue.Category);
writer.WriteIdIfNotNull(RedmineKeys.TRACKER_ID, issue.Tracker);
writer.WriteIdIfNotNull(RedmineKeys.ASSIGNED_TO_ID, issue.AssignedTo);
writer.WriteIdIfNotNull(RedmineKeys.FIXED_VERSION_ID, issue.FixedVersion);
writer.WriteValueOrEmpty(RedmineKeys.ESTIMATED_HOURS, issue.EstimatedHours);
writer.WriteIdOrEmpty(RedmineKeys.PARENT_ISSUE_ID, issue.ParentIssue);
writer.WriteDateOrEmpty(RedmineKeys.START_DATE, issue.StartDate);
writer.WriteDateOrEmpty(RedmineKeys.DUE_DATE, issue.DueDate);
writer.WriteDateOrEmpty(RedmineKeys.UPDATED_ON, issue.DueDate);
if (issue.DoneRatio != null)
writer.WriteProperty(RedmineKeys.DONE_RATIO, issue.DoneRatio.Value.ToString(CultureInfo.InvariantCulture));
if (issue.SpentHours != null)
writer.WriteProperty(RedmineKeys.SPENT_HOURS, issue.SpentHours.Value.ToString(CultureInfo.InvariantCulture));
writer.WriteArray(RedmineKeys.UPLOADS, issue.Uploads, new UploadConverter(), serializer);
writer.WriteArray(RedmineKeys.CUSTOM_FIELDS, issue.CustomFields, new IssueCustomFieldConverter(), serializer);
writer.WriteIdsArray(RedmineKeys.WATCHER_USER_IDS, issue.Watchers);
writer.WriteEndObject();
}
示例8: 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();
}
示例9: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
var request = value as AtomicCountersRequest;
if (request == null)
{
writer.WriteNull();
return;
}
writer.WriteStartObject();
writer.WritePropertyName(request.Property );
writer.WriteStartObject();
if( request.IncrementBy > 0 )
writer.WriteProperty("incrementby", request.IncrementBy.ToString());
if( request.DecrementBy > 0 )
writer.WriteProperty("decrementby", request.DecrementBy.ToString());
writer.WriteEndObject();
writer.WriteEndObject();
}
示例10: WriteWpOptions
private void WriteWpOptions(JsonWriter writer, WindowsPhoneOptions options)
{
writer.WriteProperty("wp");
if (options.Notification.WPNotificationType == WPNotificationType.Toast)
WriteToastOptions(writer, options.Notification as ToastNotification);
else if (options.Notification.WPNotificationType == WPNotificationType.Tile)
WriteTileOptions(writer, options.Notification as TileNotification);
if (options.Notification.WPNotificationType == WPNotificationType.Raw)
WriteRawOptions(writer, options.Notification as RawNotification);
}
示例11: Serialize
public void Serialize(JsonWriter writer, object obj, JsonSerializer serializer)
{
if (obj == null) return;
var item = (IssueCustomField)obj;
if (item.Values == null) return;
var count = item.Values.Count;
if (count > 1)
{
writer.WriteProperty(RedmineKeys.VALUE, item.Values.Select(x => x.Info).ToArray());
}
else
{
writer.WriteProperty(RedmineKeys.VALUE, count > 0 ? item.Values[0].Info : null);
}
}
示例12: WriteJson
protected override void WriteJson(Entity entity, JsonWriter writer, JsonSerializer serializer)
{
if (entity == null)
return;
var device = entity as Device;
if (device != null)
{
writer
.WriteProperty("__schemaid", device.SchemaId);
}
}
示例13: WriteRandomScore
private bool WriteRandomScore(JsonWriter writer, IRandomScoreFunction value, JsonSerializer serializer)
{
if (value == null) return false;
writer.WritePropertyName("random_score");
writer.WriteStartObject();
{
writer.WriteProperty(serializer, "seed", value.Seed);
}
writer.WriteEndObject();
return true;
}
示例14: WriteJson
protected override void WriteJson(Entity entity, JsonWriter writer, JsonSerializer serializer)
{
if (entity == null)
return;
var user = entity as User;
if (user != null)
{
writer
.WriteProperty("__schemaid", user.SchemaId);
}
}
示例15: WriteScriptScore
private bool WriteScriptScore(JsonWriter writer, IScriptScoreFunction value, JsonSerializer serializer)
{
if (value == null) return false;
writer.WritePropertyName("script_score");
writer.WriteStartObject();
{
writer.WriteProperty(serializer, "script", value.Script);
}
writer.WriteEndObject();
return true;
}