本文整理汇总了C#中Newtonsoft.Json.JsonWriter.WriteRawValue方法的典型用法代码示例。如果您正苦于以下问题:C# JsonWriter.WriteRawValue方法的具体用法?C# JsonWriter.WriteRawValue怎么用?C# JsonWriter.WriteRawValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Newtonsoft.Json.JsonWriter
的用法示例。
在下文中一共展示了JsonWriter.WriteRawValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
Route route = (Route)value;
writer.WriteStartObject();
writer.WritePropertyName("id");
writer.WriteValue(route.Id);
writer.WritePropertyName("length");
writer.WriteValue(route.Length);
writer.WritePropertyName("line");
writer.WriteRawValue(JsonConvert.SerializeObject(route.Line));
writer.WritePropertyName("maxM");
writer.WriteValue(route.MaxM);
writer.WritePropertyName("minM");
writer.WriteValue(route.MinM);
writer.WritePropertyName("region");
writer.WriteRawValue(JsonConvert.SerializeObject(route.Region));
writer.WritePropertyName("parts");
writer.WriteRawValue(JsonConvert.SerializeObject(route.Parts));
writer.WritePropertyName("style");
writer.WriteRawValue(JsonConvert.SerializeObject(route.Style));
writer.WritePropertyName("type");
writer.WriteValue(route.Type);
writer.WritePropertyName("points");
writer.WriteRawValue(JsonConvert.SerializeObject(route.Points));
writer.WriteEndObject();
}
示例2: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
PacketEffect effect = (PacketEffect)value;
PacketEffectAttribute effectAttribute = effect.GetType().GetCustomAttribute<PacketEffectAttribute>();
if (effectAttribute == null)
throw new NotSupportedException("All PacketEffect classes must have a PacketEffectAttribute !");
writer.WriteStartObject();
writer.WritePropertyName(effectAttribute.Name);
writer.WriteStartObject();
foreach (PropertyInfo info in value.GetType().GetProperties())
{
string propertyName;
JsonPropertyAttribute propertyAttribute = info.GetCustomAttribute<JsonPropertyAttribute>();
if (propertyAttribute != null)
propertyName = propertyAttribute.PropertyName;
else
propertyName = info.Name;
writer.WritePropertyName(propertyName);
JsonConverterAttribute conversionAttribute = info.GetCustomAttribute<JsonConverterAttribute>();
if (conversionAttribute != null)
writer.WriteRawValue(JsonConvert.SerializeObject(info.GetValue(value), Formatting.None, (JsonConverter)Activator.CreateInstance(conversionAttribute.ConverterType)));
else
writer.WriteRawValue(JsonConvert.SerializeObject(info.GetValue(value)));
}
writer.WriteEndObject();
writer.WriteEndObject();
}
示例3: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
if (value is string)
{
if (Value_RE.Match(value.ToString()).Success)
{
writer.WriteRawValue(value.ToString());
}
else
{
string prms;
switch (this.Name)
{
case "before":
prms = "el,type,action,extraParams,o";
break;
case "complete":
prms = "success,response,result,el,type,action,extraParams,o";
break;
default:
prms = "response,result,el,type,action,extraParams,o";
break;
}
value = TokenUtils.ReplaceRawToken(TokenUtils.ParseTokens(value.ToString(), this.OwnerControl));
writer.WriteRawValue(new JFunction((string)value, prms).ToScript());
}
}
}
示例4: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
if (value != null && value is ComponentListener)
{
ComponentListener componentListener = (ComponentListener)value;
if (!componentListener.IsDefault)
{
if (this.Owner is StateManagedItem)
{
componentListener.Owner = ((StateManagedItem)this.Owner).Owner;
}
else if (this.Owner is Control)
{
componentListener.Owner = (Control)this.Owner;
}
componentListener.SetArgumentList(this.Owner.GetType().GetProperty(this.PropertyName));
writer.WriteRawValue(new ClientConfig().Serialize(componentListener));
return;
}
}
writer.WriteRawValue("{}");
}
示例5: WriteJson
/// <summary>${WP_REST_RectConverter_method_WriteJson_D}</summary>
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
Rect rect = (Rect)value;
PointConverter ponitConverter = new PointConverter();
writer.WriteStartObject();
writer.WritePropertyName("rightBottom");
writer.WriteRawValue(JsonConvert.SerializeObject(new Point(rect.Right,rect.Bottom), ponitConverter));
writer.WritePropertyName("leftTop");
writer.WriteRawValue(JsonConvert.SerializeObject(new Point(rect.Left, rect.Top), ponitConverter));
writer.WriteEndObject();
}
示例6: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
if (value != null && value is Renderer)
{
string temp = ((Renderer)value).ToConfigString();
if (temp.IsNotEmpty())
{
writer.WriteRawValue(temp);
return;
}
}
writer.WriteRawValue("null");
}
示例7: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
switch ((ThreeStateBool)value)
{
case ThreeStateBool.False:
writer.WriteRawValue("false");
return;
case ThreeStateBool.True:
writer.WriteRawValue("true");
return;
}
writer.WriteRawValue("undefined");
}
示例8: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
ElasticQuery term = (ElasticQuery)value;
if (term != null)
{
writer.WriteStartObject();
writer.WriteRaw("\"from\": " + term.From);
writer.WriteRaw(",\"size\": " + term.Size + ",");
writer.WritePropertyName("query");
serializer.Serialize(writer, term.Query);
if (term.Fields != null && term.Fields.Count > 0)
{
writer.WritePropertyName("fields");
writer.WriteStartArray();
foreach (var field in term.Fields)
{
writer.WriteRawValue("\"" + field + "\"");
}
writer.WriteEndArray();
}
if (term.SortItems != null && term.SortItems.Count > 0)
{
writer.WritePropertyName("sort");
writer.WriteStartObject();
foreach (var sortItem in term.SortItems)
{
if (sortItem != null)
{
writer.WritePropertyName(sortItem.FieldName);
writer.WriteValue(sortItem.SortType.ToString().ToLower());
}
}
writer.WriteEndObject();
}
//facets
if (term.Facets != null)
{
writer.WritePropertyName("facets");
serializer.Serialize(writer, term.Facets);
}
//hightlight
if(term.Hightlight!=null)
{
writer.WritePropertyName("highlight");
serializer.Serialize(writer,term.Hightlight);
}
if (term.Explain)
{
writer.WriteRaw(",\"explain\": " + term.Explain.ToString().ToLower());
}
writer.WriteEndObject();
}
}
示例9: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
TermsFilter term = (TermsFilter)value;
if (term != null)
{
var stringBuilder = new StringBuilder();
stringBuilder.Append("{ \"terms\" : { \"" + term.Field + "\" : [");
var i = 0;
foreach (var t in term.Values)
{
if (i > 0)
{
stringBuilder.Append(",");
}
stringBuilder.Append("\"" + t + "\"");
i++;
}
stringBuilder.Append("]");
// stringBuilder.Append(",\"_cache\": " + term.Cache.ToString().ToLower());
stringBuilder.Append("}}");
writer.WriteRawValue(stringBuilder.ToString());
}
}
示例10: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
var item = (LogEventInfoItem)value;
writer.WriteStartObject();
writer.WritePropertyName("ItemId");
writer.WriteValue(item.ItemId);
writer.WritePropertyName("SequenceId");
writer.WriteValue(item.SequenceId);
writer.WritePropertyName("TimeStamp");
writer.WriteValue(new DateTimeOffset(item.DateTimeUtc));
writer.WritePropertyName("Level");
writer.WriteValue(item.Level.ToString());
writer.WritePropertyName("Logger");
writer.WriteValue(item.Logger);
writer.WritePropertyName("Message");
writer.WriteValue(item.Message);
// exception?
writer.WritePropertyName("ExceptionWrapper");
var wrapper = item.GetExceptionWrapper();
if (wrapper != null)
writer.WriteRawValue(wrapper.ToJson());
else
writer.WriteValue((object)null);
writer.WriteEndObject();
}
示例11: WriteJson
public override JsonWriter WriteJson(JsonWriter writer)
{
if(Filters.Count > 0)
{
writer.WritePropertyName("inputs");
writer.WriteStartObject();
writer.WritePropertyName("bucket");
writer.WriteValue(_bucket);
writer.WritePropertyName("key_filters");
writer.WriteStartArray();
Filters.ForEach(f => writer.WriteRawValue(f.ToJsonString()));
writer.WriteEndArray();
writer.WriteEndObject();
}
else
{
writer.WritePropertyName("inputs");
writer.WriteValue(_bucket);
}
return writer;
}
示例12: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
if (value is string)
{
writer.WriteRawValue(new JFunction((string)value).ToScript());
}
}
示例13: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
IList items = (IList)value;
if (value != null && items.Count > 0)
{
if (items.Count == 1 && !CanBeSingleItemArray(items[0]))
{
Control item = (Control)items[0];
PanelBase pnl = item as PanelBase;
if (!item.Visible || (pnl != null && pnl.Hidden && pnl.ParentComponent is TabPanel))
{
writer.WriteNull();
return;
}
writer.WriteRawValue(this.Format(items[0] as Control));
}
else
{
bool visible = false;
foreach (Observable item in items)
{
PanelBase pnl = item as PanelBase;
bool isTab = pnl != null && pnl.ParentComponent is TabPanel;
if (item.Visible && (!isTab || !pnl.Hidden))
{
visible = true;
}
}
if (visible)
{
writer.WriteStartArray();
foreach (Observable item in items)
{
PanelBase pnl = item as PanelBase;
bool isTab = pnl != null && pnl.ParentComponent is TabPanel;
if (item.Visible && (!isTab || !pnl.Hidden))
{
writer.WriteRawValue(this.Format(item));
}
}
writer.WriteEndArray();
}
else
{
writer.WriteNull();
}
}
}
}
示例14: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
WildcardQuery term = (WildcardQuery)value;
if (term != null)
writer.WriteRawValue(string.Format("{{ wildcard: {{ \"{0}\" : {{ \"wildcard\" : \"{1}\", \"boost\":{2} }}}} }}", term.Field, term.WildCardPattern, term.Boost));
}
示例15: Serialize
public void Serialize(JsonWriter writer)
{
if (string.IsNullOrWhiteSpace(MimeType) || string.IsNullOrWhiteSpace(Content))
return;
var sb = new StringBuilder();
var sw = new StringWriter(sb);
using (JsonWriter jw = new JsonTextWriter(sw))
{
jw.WritePropertyName(MimeType);
jw.WriteStartObject();
if (!string.IsNullOrWhiteSpace(Content))
{
jw.WriteRawValue(Content);
}
jw.WriteEndObject();
if (jw.WriteState == WriteState.Error)
sb.Clear();
}
writer.WriteRawValue(sb.ToString());
}