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


C# JsonWriter.WriteEnd方法代码示例

本文整理汇总了C#中Newtonsoft.Json.JsonWriter.WriteEnd方法的典型用法代码示例。如果您正苦于以下问题:C# JsonWriter.WriteEnd方法的具体用法?C# JsonWriter.WriteEnd怎么用?C# JsonWriter.WriteEnd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Newtonsoft.Json.JsonWriter的用法示例。


在下文中一共展示了JsonWriter.WriteEnd方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WriteJson

 public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
 {
     writer.Formatting = Newtonsoft.Json.Formatting.Indented;
     writer.WritePropertyName("ObjectId");
     writer.WriteValue(((ObjectId) value).ToString());
     writer.WriteEnd();
 }
开发者ID:ahmetoz,项目名称:Photopia,代码行数:7,代码来源:MongoObjectIdConverter.cs

示例2: WriteJson

 public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
 {
     var la = (IGroup)value;
     writer.WriteStartObject();
     writer.WritePropertyName("name");
     writer.WriteValue(la.Name);
     writer.WritePropertyName("lights");
     serializer.Serialize(writer, la.Lights);
     writer.WriteEnd();
 }
开发者ID:JacquiManzi,项目名称:KineticSpectrum,代码行数:10,代码来源:GroupConverter.cs

示例3: WriteProperties

        internal void WriteProperties(JsonWriter jsonWriter)
        {
            var properties = this._type.GetProperties();
            foreach (var p in properties)
            {
                var att = ElasticAttributes.Property(p);
                if (att != null && att.OptOut)
                    continue;

                var propertyName = this.Infer.PropertyName(p);
                var type = GetElasticSearchType(att, p);

                if (type == null) //could not get type from attribute or infer from CLR type.
                    continue;

                jsonWriter.WritePropertyName(propertyName);
                jsonWriter.WriteStartObject();
                {
                    if (att == null) //properties that follow can not be inferred from the CLR.
                    {
                        jsonWriter.WritePropertyName("type");
                        jsonWriter.WriteValue(type);
                        //jsonWriter.WriteEnd();
                    }
                    if (att != null)
                        this.WritePropertiesFromAttribute(jsonWriter, att, propertyName, type);
                    if (type == "object" || type == "nested")
                    {

                        var deepType = p.PropertyType;
                        var deepTypeName = this.Infer.TypeName(deepType);
                        var seenTypes = new ConcurrentDictionary<Type, int>(this.SeenTypes);
                        seenTypes.AddOrUpdate(deepType, 0, (t, i) => ++i);

                        var newTypeMappingWriter = new TypeMappingWriter(deepType, deepTypeName, this._connectionSettings, MaxRecursion, seenTypes);
                        var nestedProperties = newTypeMappingWriter.MapPropertiesFromAttributes();

                        jsonWriter.WritePropertyName("properties");
                        nestedProperties.WriteTo(jsonWriter);
                    }
                }
                jsonWriter.WriteEnd();
            }
        }
开发者ID:rantsi,项目名称:elasticsearch-net,代码行数:44,代码来源:TypeMappingWriter.cs

示例4: HandleError

 private void HandleError(JsonWriter writer, int initialDepth)
 {
   this.ClearErrorContext();
   if (writer.WriteState == WriteState.Property)
     writer.WriteNull();
   while (writer.Top > initialDepth)
     writer.WriteEnd();
 }
开发者ID:Zeludon,项目名称:FEZ,代码行数:8,代码来源:JsonSerializerInternalWriter.cs

示例5: Indenting

		public void Indenting()
		{
			StringBuilder sb = new StringBuilder();
			StringWriter sw = new StringWriter(sb);

			using (JsonWriter jsonWriter = new JsonWriter(sw))
			{
				jsonWriter.Formatting = Formatting.Indented;

				jsonWriter.WriteStartObject();
				jsonWriter.WritePropertyName("CPU");
				jsonWriter.WriteValue("Intel");
				jsonWriter.WritePropertyName("PSU");
				jsonWriter.WriteValue("500W");
				jsonWriter.WritePropertyName("Drives");
				jsonWriter.WriteStartArray();
				jsonWriter.WriteValue("DVD read/writer");
				jsonWriter.WriteComment("(broken)");
				jsonWriter.WriteValue("500 gigabyte hard drive");
				jsonWriter.WriteValue("200 gigabype hard drive");
				jsonWriter.WriteEnd();
				jsonWriter.WriteEndObject();
			}

			string expected = @"{
  ""CPU"": ""Intel"",
  ""PSU"": ""500W"",
  ""Drives"": [
    ""DVD read/writer""
    /*(broken)*/,
    ""500 gigabyte hard drive"",
    ""200 gigabype hard drive""
  ]
}";
			string result = sb.ToString();

			Console.WriteLine("Indenting");
			Console.WriteLine(result);

			Assert.AreEqual(expected, result);
		}
开发者ID:mrkurt,项目名称:mubble-old,代码行数:41,代码来源:JsonWriterTest.cs

示例6: State

		public void State()
		{
			StringBuilder sb = new StringBuilder();
			StringWriter sw = new StringWriter(sb);

			using (JsonWriter jsonWriter = new JsonWriter(sw))
			{
				Assert.AreEqual(WriteState.Start, jsonWriter.WriteState);

				jsonWriter.WriteStartObject();
				Assert.AreEqual(WriteState.Object, jsonWriter.WriteState);
				
				jsonWriter.WritePropertyName("CPU");
				Assert.AreEqual(WriteState.Property, jsonWriter.WriteState);

				jsonWriter.WriteValue("Intel");
				Assert.AreEqual(WriteState.Object, jsonWriter.WriteState);

				jsonWriter.WritePropertyName("Drives");
				Assert.AreEqual(WriteState.Property, jsonWriter.WriteState);

				jsonWriter.WriteStartArray();
				Assert.AreEqual(WriteState.Array, jsonWriter.WriteState);

				jsonWriter.WriteValue("DVD read/writer");
				Assert.AreEqual(WriteState.Array, jsonWriter.WriteState);

				jsonWriter.WriteEnd();
				Assert.AreEqual(WriteState.Object, jsonWriter.WriteState);

				jsonWriter.WriteEndObject();
				Assert.AreEqual(WriteState.Start, jsonWriter.WriteState);
			}
		}
开发者ID:mrkurt,项目名称:mubble-old,代码行数:34,代码来源:JsonWriterTest.cs

示例7: WriteJson

        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            var document = value as DocumentRevision;
            writer.WriteStartObject();

            if (!string.IsNullOrEmpty(document.docId))
            {
                writer.WritePropertyName("_id");
                serializer.Serialize(writer, document.docId);
            }

            if (!string.IsNullOrEmpty(document.revId))
            {
                writer.WritePropertyName("_rev");
                serializer.Serialize(writer, document.revId);
            }
            if (document.isDeleted)
            {
                writer.WritePropertyName("_deleted");
                serializer.Serialize(writer, document.isDeleted);
            }

            foreach (var pair in document.body)
            {
                writer.WritePropertyName(pair.Key);
                serializer.Serialize(writer, pair.Value);
            }

            writer.WriteEnd();
        }
开发者ID:cloudant,项目名称:xamarin-cloudant,代码行数:30,代码来源:DocumentRevisionConverter.cs


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