本文整理汇总了C#中JsonWriter.WritePropertyName方法的典型用法代码示例。如果您正苦于以下问题:C# JsonWriter.WritePropertyName方法的具体用法?C# JsonWriter.WritePropertyName怎么用?C# JsonWriter.WritePropertyName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonWriter
的用法示例。
在下文中一共展示了JsonWriter.WritePropertyName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
var dataResult = value as DataResult;
#region 序列化DataResult对象
writer.WriteStartObject();
// 写total属性
writer.WritePropertyName("total");
serializer.Serialize(writer, dataResult.Total);
// 写pagecount属性
writer.WritePropertyName("pagecount");
serializer.Serialize(writer, dataResult.PageCount);
// 写pageindex属性
writer.WritePropertyName("pageindex");
serializer.Serialize(writer, dataResult.PageIndex);
// 写rows属性
var converter = new DataTableConverter();
writer.WritePropertyName("rows");
converter.WriteJson(writer, dataResult.Data, serializer);
writer.WriteEndObject();
#endregion
}
示例2: SaveColour
public static void SaveColour(JsonWriter writer, string propertyName, Color entry)
{
if (writer == null)
{
return;
}
writer.WritePropertyName(propertyName);
writer.WriteStartObject();
writer.WritePropertyName("r");
writer.WriteValue(entry.r);
writer.WritePropertyName("g");
writer.WriteValue(entry.g);
writer.WritePropertyName("b");
writer.WriteValue(entry.b);
writer.WritePropertyName("a");
writer.WriteValue(entry.a);
writer.WriteEndObject();
}
示例3: WriteJson
/// <summary>
/// Writes the JSON representation of the object.
/// </summary>
/// <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)
{
DefaultContractResolver resolver = serializer.ContractResolver as DefaultContractResolver;
IEntityKeyMember entityKeyMember = DynamicWrapper.CreateWrapper<IEntityKeyMember>(value);
Type keyType = (entityKeyMember.Value != null) ? entityKeyMember.Value.GetType() : null;
writer.WriteStartObject();
writer.WritePropertyName((resolver != null) ? resolver.GetResolvedPropertyName(KeyPropertyName) : KeyPropertyName);
writer.WriteValue(entityKeyMember.Key);
writer.WritePropertyName((resolver != null) ? resolver.GetResolvedPropertyName(TypePropertyName) : TypePropertyName);
writer.WriteValue((keyType != null) ? keyType.FullName : null);
writer.WritePropertyName((resolver != null) ? resolver.GetResolvedPropertyName(ValuePropertyName) : ValuePropertyName);
if (keyType != null)
{
string valueJson;
if (JsonSerializerInternalWriter.TryConvertToString(entityKeyMember.Value, keyType, out valueJson))
writer.WriteValue(valueJson);
else
writer.WriteValue(entityKeyMember.Value);
}
else
{
writer.WriteNull();
}
writer.WriteEndObject();
}
示例4: WriteJson
/// <summary>
/// Writes the JSON representation of the object.
/// </summary>
/// <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)
{
IEntityKeyMember entityKeyMember = DynamicWrapper.CreateWrapper<IEntityKeyMember>(value);
Type keyType = (entityKeyMember.Value != null) ? entityKeyMember.Value.GetType() : null;
writer.WriteStartObject();
writer.WritePropertyName("Key");
writer.WriteValue(entityKeyMember.Key);
writer.WritePropertyName("Type");
writer.WriteValue((keyType != null) ? keyType.FullName : null);
writer.WritePropertyName("Value");
if (keyType != null)
{
string valueJson;
if (JsonSerializerInternalWriter.TryConvertToString(entityKeyMember.Value, keyType, out valueJson))
writer.WriteValue(valueJson);
else
writer.WriteValue(entityKeyMember.Value);
}
else
{
writer.WriteNull();
}
writer.WriteEndObject();
}
示例5: WriteJson
/// <summary>
/// Writes the JSON representation of the object.
/// </summary>
/// <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)
{
EnsureReflectionObject(value.GetType());
DefaultContractResolver resolver = serializer.ContractResolver as DefaultContractResolver;
string keyName = (string)_reflectionObject.GetValue(value, KeyPropertyName);
object keyValue = _reflectionObject.GetValue(value, ValuePropertyName);
Type keyValueType = (keyValue != null) ? keyValue.GetType() : null;
writer.WriteStartObject();
writer.WritePropertyName((resolver != null) ? resolver.GetResolvedPropertyName(KeyPropertyName) : KeyPropertyName);
writer.WriteValue(keyName);
writer.WritePropertyName((resolver != null) ? resolver.GetResolvedPropertyName(TypePropertyName) : TypePropertyName);
writer.WriteValue((keyValueType != null) ? keyValueType.FullName : null);
writer.WritePropertyName((resolver != null) ? resolver.GetResolvedPropertyName(ValuePropertyName) : ValuePropertyName);
if (keyValueType != null)
{
string valueJson;
if (JsonSerializerInternalWriter.TryConvertToString(keyValue, keyValueType, out valueJson))
writer.WriteValue(valueJson);
else
writer.WriteValue(keyValue);
}
else
{
writer.WriteNull();
}
writer.WriteEndObject();
}
示例6: WriteJson
private void WriteJson(JsonWriter writer, Regex regex)
{
writer.WriteStartObject();
writer.WritePropertyName("Pattern");
writer.WriteValue(regex.ToString());
writer.WritePropertyName("Options");
writer.WriteValue(regex.Options);
writer.WriteEndObject();
}
示例7: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
var vec = (Vector2)value;
writer.WriteStartObject();
writer.WritePropertyName("x");
writer.WriteValue(vec.x);
writer.WritePropertyName("y");
writer.WriteValue(vec.y);
writer.WriteEndObject();
}
示例8: WriteJson
/// <summary>
/// Writes the JSON representation of the object.
/// </summary>
/// <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)
{
Type t = value.GetType();
PropertyInfo keyProperty = t.GetProperty("Key");
PropertyInfo valueProperty = t.GetProperty("Value");
writer.WriteStartObject();
writer.WritePropertyName("Key");
serializer.Serialize(writer, ReflectionUtils.GetMemberValue(keyProperty, value));
writer.WritePropertyName("Value");
serializer.Serialize(writer, ReflectionUtils.GetMemberValue(valueProperty, value));
writer.WriteEndObject();
}
示例9: WriteJson
/// <summary>
/// Writes the JSON representation of the object.
/// </summary>
/// <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)
{
ReflectionObject reflectionObject = ReflectionObjectPerType.Get(value.GetType());
DefaultContractResolver resolver = serializer.ContractResolver as DefaultContractResolver;
writer.WriteStartObject();
writer.WritePropertyName((resolver != null) ? resolver.GetResolvedPropertyName(KeyName) : KeyName);
serializer.Serialize(writer, reflectionObject.GetValue(value, KeyName), reflectionObject.GetType(KeyName));
writer.WritePropertyName((resolver != null) ? resolver.GetResolvedPropertyName(ValueName) : ValueName);
serializer.Serialize(writer, reflectionObject.GetValue(value, ValueName), reflectionObject.GetType(ValueName));
writer.WriteEndObject();
}
示例10: ToString
public override string ToString()
{
StringBuilder sb = new StringBuilder ();
JsonWriter writer = new JsonWriter (sb);
writer.WriteObjectStart ();
writer.WritePropertyName ("option");
writer.Write (option);
writer.WritePropertyName ("subfield");
writer.Write (subfield);
writer.WritePropertyName ("tarId");
writer.Write (tarId);
writer.WriteObjectEnd ();
return sb.ToString();
}
示例11: Deactivate
void Deactivate()
{
state = 0;
renderer.material.color = colours[0];
StringBuilder sb = new StringBuilder();
JsonWriter writer = new JsonWriter(sb);
writer.WriteObjectStart();
writer.WritePropertyName("id");
writer.Write(id);
writer.WritePropertyName("state");
writer.Write(0);
writer.WriteObjectEnd();
monome.SendMessage("SendToSaul", sb.ToString());
}
示例12: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
if (value == null)
{
writer.WriteValue("null");
return;
}
var processResult = (ProcessResult)value;
writer.WriteStartObject();
writer.WritePropertyName("missingSnippets");
serializer.Serialize(writer, processResult.MissingSnippets);
writer.WritePropertyName("usedSnippets");
serializer.Serialize(writer, processResult.UsedSnippets);
writer.WriteEndObject();
}
示例13: CreateClothes
public static void CreateClothes()
{
string[] materials = Directory.GetFiles("Assets/characters_joysoft", "*.mat", SearchOption.AllDirectories);
StringBuilder sbuilders = new StringBuilder ();
JsonWriter writer = new JsonWriter (sbuilders);
writer.WriteObjectStart ();
foreach (string material in materials)
{
//Assets/characters_joysoft/Per Texture Materials/female_hair_01_01.mat
string[] parts=material.Replace(".mat","").Split('/');
string unit=parts[parts.Length-1];
writer.WritePropertyName (unit);
int hashkey=0;
foreach(string key in defaultClothes){
if(unit.Contains(key)){
hashkey=1;
break;
}
}
writer.Write (""+hashkey);
sbuilders.Append(System.Environment.NewLine);
}
writer.WriteObjectEnd ();
UpdateClothesContent(sbuilders);
Debug.Log("**********UpdateClothesContent Finish***********");
}
示例14: WriteToService
public void WriteToService()
{
System.Text.StringBuilder m_write = new System.Text.StringBuilder();
JsonWriter m_writer = new JsonWriter(m_write);
m_writer.WriteObjectStart();
m_writer.WritePropertyName("ButtonID");
}
示例15: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
if (value == null)
{
writer.WriteValue("null");
return;
}
var readSnippets = (ReadSnippets)value;
writer.WriteStartObject();
writer.WritePropertyName("snippets");
serializer.Serialize(writer, readSnippets.Snippets);
writer.WritePropertyName("errors");
serializer.Serialize(writer, readSnippets.Errors);
writer.WriteEndObject();
}