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


C# JsonWriter.WriteName方法代码示例

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


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

示例1: WritesTwoPropertyObject

 public void WritesTwoPropertyObject()
 {
     var sw = new StringWriter();
     var writer = new JsonWriter(sw);
     writer.WriteStartObject();
     writer.WriteName("A").WriteValue(1);
     writer.WriteName("B").WriteValue(2);
     writer.WriteEnd();
     Assert.AreEqual("{\"A\": 1, \"B\": 2}", sw.ToString());
 }
开发者ID:ALyman,项目名称:Liquid.Json,代码行数:10,代码来源:Objects.cs

示例2: NameWithoutObject

 public void NameWithoutObject()
 {
     var sw = new StringWriter();
     var writer = new JsonWriter(sw);
     try {
         writer.WriteName("X");
         Assert.Fail("Did not throw the expected exception");
     } catch (NotSupportedException ex) {
         Assert.AreEqual("Must be inside an object to write a name", ex.Message);
     }
 }
开发者ID:ALyman,项目名称:Liquid.Json,代码行数:11,代码来源:Malformed.cs

示例3: ExportAsJsonSensorData

		/// <summary>
		/// <see cref="Field.ExportAsJsonSensorData"/>
		/// </summary>
		public override void ExportAsJsonSensorData(JsonWriter w)
		{
			w.BeginObject ();

			w.WriteName ("fieldType");
			w.WriteValue ("boolean");

			this.ExportAsJsonSensorDataCommonAttributes(w);

			w.WriteName ("value");
			w.WriteValue (this.value);

			w.WriteName ("datatype");
			w.WriteValue (this.dataType);

			w.EndObject ();
		}
开发者ID:mukira,项目名称:Learning-IoT-HTTP,代码行数:20,代码来源:FieldEnum.cs

示例4: ExportAsJsonSensorData

		/// <summary>
		/// <see cref="Field.ExportAsJsonSensorData"/>
		/// </summary>
		public override void ExportAsJsonSensorData(JsonWriter w)
		{
			w.BeginObject ();

			w.WriteName ("fieldType");
			w.WriteValue ("dateTime");

			this.ExportAsJsonSensorDataCommonAttributes(w);

			w.WriteName ("year");
			w.WriteValue (this.value.Year);

			w.WriteName ("month");
			w.WriteValue (this.value.Month);

			w.WriteName ("day");
			w.WriteValue (this.value.Day);

			w.WriteName ("hour");
			w.WriteValue (this.value.Hour);

			w.WriteName ("minute");
			w.WriteValue (this.value.Minute);

			w.WriteName ("second");
			w.WriteValue (this.value.Second);

			w.EndObject ();
		}
开发者ID:mukira,项目名称:Learning-IoT-HTTP,代码行数:32,代码来源:FieldDateTime.cs

示例5: StartExportTimestamp

		/// <summary>
		/// Starts the export of sensor data values for a particular point in time. This call must be followed by a call to <see cref="EndExportTimestamp"/>.
		/// Use <see cref="ExportField"/> to export field  information to the Sensor Data JSON document.
		/// </summary>
		/// <param name="Json">JSON Output</param>
		/// <param name="Timestamp">Timestamp</param>
		public static void StartExportTimestamp (JsonWriter Json, DateTime Timestamp)
		{
			Timestamp = Timestamp.ToUniversalTime ();

			Json.BeginObject ();

			Json.WriteName ("timestampUtc");
			Json.BeginObject ();

			Json.WriteName ("year");
			Json.WriteValue (Timestamp.Year);

			Json.WriteName ("month");
			Json.WriteValue (Timestamp.Month);

			Json.WriteName ("day");
			Json.WriteValue (Timestamp.Day);

			Json.WriteName ("hour");
			Json.WriteValue (Timestamp.Hour);

			Json.WriteName ("minute");
			Json.WriteValue (Timestamp.Minute);

			Json.WriteName ("second");
			Json.WriteValue (Timestamp.Second);

			Json.EndObject ();

			Json.WriteName ("fields");
			Json.BeginArray ();
		}
开发者ID:mukira,项目名称:Learning-IoT-HTTP,代码行数:38,代码来源:Export.cs

示例6: StartExportNode

		/// <summary>
		/// Starts the export of sensor data values for a particular node. This call must be followed by a call to <see cref="EndExportNode"/>.
		/// Use <see cref="StartExportTimestamp"/> to export node information pertaining to a given point in time to the Sensor Data JSON document.
		/// </summary>
		/// <param name="Json">JSON Output</param>
		/// <param name="NodeId">Node ID.</param>
		/// <param name="CacheType">Cache Type</param> 
		/// <param name="SourceId">Source ID.</param>
		public static void StartExportNode (JsonWriter Json, string NodeId, string CacheType, string SourceId)
		{
			Json.BeginObject ();

			Json.WriteName ("nodeId");
			Json.WriteValue (NodeId);

			if (!string.IsNullOrEmpty (CacheType))
			{
				Json.WriteName ("cacheType");
				Json.WriteValue (CacheType);
			}

			if (!string.IsNullOrEmpty (SourceId))
			{
				Json.WriteName ("sourceId");
				Json.WriteValue (SourceId);
			}

			Json.WriteName ("timestamps");
			Json.BeginArray ();
		}
开发者ID:mukira,项目名称:Learning-IoT-HTTP,代码行数:30,代码来源:Export.cs

示例7: ExportAsJsonSensorData

		/// <summary>
		/// <see cref="Field.ExportAsJsonSensorData"/>
		/// </summary>
		public override void ExportAsJsonSensorData(JsonWriter w)
		{
			w.BeginObject ();

			w.WriteName ("fieldType");
			w.WriteValue ("numeric");

			this.ExportAsJsonSensorDataCommonAttributes(w);

			w.WriteName ("value");
			w.WriteValue (this.value);

			w.WriteName ("unit");
			w.WriteValue (this.unit);

			w.WriteName ("nrDec");
			w.WriteValue (this.nrDecimals);

			w.EndObject ();
		}
开发者ID:mukira,项目名称:Learning-IoT-HTTP,代码行数:23,代码来源:FieldNumeric.cs

示例8: ExportAsJsonSensorData

		/// <summary>
		/// <see cref="Field.ExportAsJsonSensorData"/>
		/// </summary>
		public override void ExportAsJsonSensorData(JsonWriter w)
		{
			w.BeginObject ();

			w.WriteName ("fieldType");
			w.WriteValue ("duration");

			this.ExportAsJsonSensorDataCommonAttributes(w);

			w.WriteName ("days");
			w.WriteValue (this.value.Days);

			w.WriteName ("hours");
			w.WriteValue (this.value.Hours);

			w.WriteName ("minutes");
			w.WriteValue (this.value.Minutes);

			w.WriteName ("seconds");
			w.WriteValue (this.value.Seconds);

			w.WriteName ("milliseconds");
			w.WriteValue (this.value.Milliseconds);

			w.EndObject ();
		}
开发者ID:mukira,项目名称:Learning-IoT-HTTP,代码行数:29,代码来源:FieldTimeSpan.cs

示例9: ExportAsJsonSensorDataCommonAttributes

		/// <summary>
		/// Exports common Field attributes, similar to XEP-0323 Sensor data, but using JSON.
		/// </summary>
		/// <param name="w">JSON Output</param>
		protected void ExportAsJsonSensorDataCommonAttributes (JsonWriter w)
		{
			w.WriteName ("name");
			w.WriteValue (this.fieldName);

			if ((this.type & ReadoutType.MomentaryValues) != 0)
			{
				w.WriteName ("momentary");
				w.WriteValue (true);
			}

			if ((this.type & ReadoutType.PeakValues) != 0)
			{
				w.WriteName ("peak");
				w.WriteValue (true);
			}

			if ((this.type & ReadoutType.StatusValues) != 0)
			{
				w.WriteName ("status");
				w.WriteValue (true);
			}

			if ((this.type & ReadoutType.Computed) != 0)
			{
				w.WriteName ("computed");
				w.WriteValue (true);
			}

			if ((this.type & ReadoutType.Identity) != 0)
			{
				w.WriteName ("identity");
				w.WriteValue (true);
			}

			if ((this.type & ReadoutType.HistoricalValuesSecond) != 0)
			{
				w.WriteName ("historicalSecond");
				w.WriteValue (true);
			}

			if ((this.type & ReadoutType.HistoricalValuesMinute) != 0)
			{
				w.WriteName ("historicalMinute");
				w.WriteValue (true);
			}

			if ((this.type & ReadoutType.HistoricalValuesHour) != 0)
			{
				w.WriteName ("historicalHour");
				w.WriteValue (true);
			}

			if ((this.type & ReadoutType.HistoricalValuesDay) != 0)
			{
				w.WriteName ("historicalDay");
				w.WriteValue (true);
			}

			if ((this.type & ReadoutType.HistoricalValuesWeek) != 0)
			{
				w.WriteName ("historicalWeek");
				w.WriteValue (true);
			}

			if ((this.type & ReadoutType.HistoricalValuesMonth) != 0)
			{
				w.WriteName ("historicalMonth");
				w.WriteValue (true);
			}

			if ((this.type & ReadoutType.HistoricalValuesQuarter) != 0)
			{
				w.WriteName ("historicalQuarter");
				w.WriteValue (true);
			}

			if ((this.type & ReadoutType.HistoricalValuesYear) != 0)
			{
				w.WriteName ("historicalYear");
				w.WriteValue (true);
			}

			if ((this.type & ReadoutType.HistoricalValuesOther) != 0)
			{
				w.WriteName ("historicalOther");
				w.WriteValue (true);
			}

			if ((this.status & FieldStatus.Missing) != 0)
			{
				w.WriteName ("missing");
				w.WriteValue (true);
			}

			if ((this.status & FieldStatus.AutomaticEstimate) != 0)
//.........这里部分代码省略.........
开发者ID:mukira,项目名称:Learning-IoT-HTTP,代码行数:101,代码来源:Field.cs


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