當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。