当前位置: 首页>>代码示例>>C#>>正文


C# JsonWriter.WritePropertyName方法代码示例

本文整理汇总了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
    }
开发者ID:guyuefeng,项目名称:aspnet-sample,代码行数:25,代码来源:JsonHelper3.cs

示例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();
    }
开发者ID:Blkx-Darkreaper,项目名称:Unity,代码行数:25,代码来源:SaveManager.cs

示例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();
        }
开发者ID:yonglehou,项目名称:microservice_workshop,代码行数:36,代码来源:EntityKeyMemberConverter.cs

示例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();
    }
开发者ID:Gert-Cominotto,项目名称:MvvmCross,代码行数:34,代码来源:EntityKeyMemberConverter.cs

示例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();
        }
开发者ID:BgCircle,项目名称:Newtonsoft.Json,代码行数:40,代码来源:EntityKeyMemberConverter.cs

示例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();
 }
开发者ID:CragonGame,项目名称:GameCloud.IM,代码行数:9,代码来源:RegexConverter.cs

示例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();
	}
开发者ID:YanivP,项目名称:FriendBubbles,代码行数:10,代码来源:Vector2Converter.cs

示例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();
    }
开发者ID:RecursosOnline,项目名称:c-sharp,代码行数:19,代码来源:KeyValuePairConverter.cs

示例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();
        }
开发者ID:arpitgold,项目名称:Exceptionless,代码行数:19,代码来源:KeyValuePairConverter.cs

示例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();
 }
开发者ID:fanqienano,项目名称:fanqietang,代码行数:14,代码来源:Option.cs

示例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());
    }
开发者ID:saulhardman,项目名称:monome,代码行数:16,代码来源:MonomeSquareBehaviour.cs

示例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();
    }
开发者ID:mat-mcloughlin,项目名称:CaptureSnippets,代码行数:16,代码来源:ProcessResultConverter.cs

示例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***********");
    }
开发者ID:yupassion,项目名称:Cinderella,代码行数:32,代码来源:CreateClothesData.cs

示例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");
 }
开发者ID:Venbb,项目名称:Games,代码行数:7,代码来源:jsoninfo.cs

示例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();
    }
开发者ID:mat-mcloughlin,项目名称:CaptureSnippets,代码行数:16,代码来源:ReadSnippetsConverter.cs


注:本文中的JsonWriter.WritePropertyName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。