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


C# JsonWriter.WriteValue方法代码示例

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


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

示例1: WriteJson

		public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
		{
			var collection = (NameValueCollection)value;

			writer.WriteStartObject();

			foreach (var key in collection.AllKeys)
			{
				writer.WritePropertyName(key);

				var values = collection.GetValues(key);
				if (values == null)
				{
					writer.WriteNull();
					continue;
				}
				if (values.Length == 1)
				{
					writer.WriteValue(values[0]);
				}
				else
				{
					writer.WriteStartArray();

					foreach (var item in values)
					{
						writer.WriteValue(item);
					}

					writer.WriteEndArray();
				}

			}
			writer.WriteEndObject();
		}
开发者ID:randacc,项目名称:ravendb,代码行数:35,代码来源:NameValueCollectionJsonConverter.cs

示例2: WriteJson

		public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
		{
			if (value == null)
				writer.WriteValue((object)null);
			else
				writer.WriteValue(_wktWriter.Write(value));
		}
开发者ID:sibartlett,项目名称:RavenDB.Client.Spatial,代码行数:7,代码来源:WktConverter.cs

示例3: WriteJson

		public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
		{
			if(value is DateTime)
			{
				var dateTime = ((DateTime)value);
				if (dateTime.Kind == DateTimeKind.Unspecified)
					dateTime = DateTime.SpecifyKind(dateTime, DateTimeKind.Local);
				var postFix = dateTime.Kind == DateTimeKind.Utc ? "Z" : "";
				writer.WriteValue(dateTime.ToString(Default.DateTimeFormatsToWrite + postFix, CultureInfo.InvariantCulture));
			}
			else if (value is DateTimeOffset)
			{
				var dateTimeOffset = ((DateTimeOffset) value);
				if(dateTimeOffset.Offset==TimeSpan.Zero)
				{
					writer.WriteValue(dateTimeOffset.UtcDateTime.ToString(Default.DateTimeFormatsToWrite, CultureInfo.InvariantCulture) + "Z");
				}
				else
				{
					writer.WriteValue(dateTimeOffset.ToString(Default.DateTimeOffsetFormatsToWrite, CultureInfo.InvariantCulture));
				}
			}
			else
				throw new ArgumentException(string.Format("Not idea how to process argument: '{0}'", value));
		}
开发者ID:shiranGinige,项目名称:ravendb,代码行数:25,代码来源:JsonDateTimeISO8601Converter.cs

示例4: WriteJsonCoordinate

        private static void WriteJsonCoordinate(JsonWriter writer, Coordinate coordinate, JsonSerializer serializer)
        {
            writer.WriteStartArray();

            writer.WriteValue(coordinate.X);
            writer.WriteValue(coordinate.Y);
            if (!Double.IsNaN(coordinate.Z))
                writer.WriteValue(coordinate.Z);
            
            writer.WriteEndArray();
        }
开发者ID:WimVergouwe,项目名称:ravendb,代码行数:11,代码来源:CoordinateConverters.cs

示例5: WriteJson

        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            Envelope envelope = value as Envelope;
            if (envelope == null) return;

            writer.WritePropertyName("bbox");
            writer.WriteStartArray();
            writer.WriteValue(envelope.MinX);
            writer.WriteValue(envelope.MinY);
            writer.WriteValue(envelope.MaxX);
            writer.WriteValue(envelope.MaxY);
            writer.WriteEndArray();
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:13,代码来源:EnvelopeConverter.cs

示例6: WriteJson

		/// <summary>
		/// Writes the JSON representation of the object.
		/// </summary>
		/// <param name="writer">The <see cref="T:Raven.Imports.Newtonsoft.Json.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)
		{
			if (value == null)
			{
					writer.WriteNull();
				return;
			}
			if (value.GetType() == typeof (object))
			{
				writer.WriteStartObject();
				writer.WriteEndObject();
				return;
			}

			var dynamicValue = ((IDynamicMetaObjectProvider) value).GetMetaObject(Expression.Constant(value));

			writer.WriteStartObject();
			foreach (var dynamicMemberName in dynamicValue.GetDynamicMemberNames())
			{
				writer.WritePropertyName(dynamicMemberName);
				var memberValue = DynamicUtil.GetValueDynamically(value, dynamicMemberName);
				if(memberValue == null || memberValue is ValueType || memberValue is string)
					writer.WriteValue(memberValue);
				else
					serializer.Serialize(writer, memberValue);
			}
			writer.WriteEndObject();

		}
开发者ID:925coder,项目名称:ravendb,代码行数:35,代码来源:JsonDynamicConverter.cs

示例7: TryWriteFeature

		public bool TryWriteFeature(JsonWriter writer, object value, JsonSerializer serializer)
		{
			if (!_shapeConverter.CanConvert(ObjectType.Feature))
				return false;

			ObjectType geomType = _shapeConverter.GetObjectType(value);
			if (geomType != ObjectType.Feature)
				return false;

			writer.WriteStartObject();
			writer.WritePropertyName("type");
			writer.WriteValue(Enum.GetName(typeof(ObjectType), ObjectType.Feature));

			object id;
			Dictionary<string, object> props;
			var geometry = _shapeConverter.FromFeature(value, out id, out props);

			if (id != null)
			{
				writer.WritePropertyName("id");
				serializer.Serialize(writer, id);
			}

			if (props != null && props.Count > 0)
			{
				writer.WritePropertyName("properties");
				serializer.Serialize(writer, props);
			}

			writer.WritePropertyName("geometry");
			serializer.Serialize(writer, geometry);

			writer.WriteEndObject();
			return true;
		}
开发者ID:sibartlett,项目名称:RavenDB.Client.Spatial,代码行数:35,代码来源:GeoJsonWriter.cs

示例8: WriteJson

		/// <summary>
		/// Writes the JSON representation of the object.
		/// </summary>
		/// <param name="writer">The <see cref="T:Raven.Imports.Newtonsoft.Json.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)
		{
			if(value == null)
				writer.WriteNull();
			else
				writer.WriteValue(value.ToString());
		}
开发者ID:royra,项目名称:ravendb,代码行数:13,代码来源:JsonEnumConverter.cs

示例9: WriteJson

		public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
		{
			var slice = (Slice) value;
			var buffer = new byte[slice.Count];
			Buffer.BlockCopy(slice.Array, slice.Offset, buffer, 0, slice.Count);
			writer.WriteValue(buffer);
			writer.WriteComment(slice.DebugVal);
		}
开发者ID:mattwarren,项目名称:temp.raven.storage,代码行数:8,代码来源:SliceJsonConverter.cs

示例10: WriteJson

 /// <summary>
 /// Writes the JSON representation of the object.
 /// </summary>
 /// <remarks>This will enumerate the Linq-To-Entities query before serializing it to json array</remarks>
 /// <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)
 {
     var enumerable = (IEnumerable) value;
     writer.WriteStartArray();
     foreach(var item in enumerable)
         writer.WriteValue(item);
     writer.WriteEndArray();
 }
开发者ID:heinnge,项目名称:ravendb,代码行数:15,代码来源:JsonLinqEnumerableConverter.cs

示例11: WriteJson

		public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
		{
			if(value is DateTime)
			{
				var dateTime = ((DateTime)value);
				if (dateTime.Kind == DateTimeKind.Unspecified)
					dateTime = DateTime.SpecifyKind(dateTime, DateTimeKind.Local);
                writer.WriteValue(dateTime.GetDefaultRavenFormat(dateTime.Kind == DateTimeKind.Utc));
			}
			else if (value is DateTimeOffset)
			{
				var dateTimeOffset = ((DateTimeOffset) value);
				writer.WriteValue(dateTimeOffset.ToString(Default.DateTimeOffsetFormatsToWrite, CultureInfo.InvariantCulture));
			}
			else
				throw new ArgumentException(string.Format("Not idea how to process argument: '{0}'", value));
		}
开发者ID:GorelH,项目名称:ravendb,代码行数:17,代码来源:JsonDateTimeISO8601Converter.cs

示例12: WriteJson

 public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
 {
     var etag = value as Etag;
     if (etag == null)
         writer.WriteNull();
     else
         writer.WriteValue(etag.ToString());
 }
开发者ID:j2jensen,项目名称:ravendb,代码行数:8,代码来源:EtagJsonConverter.cs

示例13: WriteJson

 public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
 {
     System.Net.IPEndPoint ep = (System.Net.IPEndPoint)value;
     writer.WriteStartObject();
     writer.WritePropertyName("Address");
     serializer.Serialize(writer, ep.Address.ToString());
     writer.WritePropertyName("Port");
     writer.WriteValue(ep.Port);
     writer.WriteEndObject();
 }
开发者ID:nahugrau,项目名称:RavenDBTests,代码行数:10,代码来源:IPEndpointConverter.cs

示例14: WriteJson

        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            var coordinate = value as Coordinate;

            if (coordinate == null)
            {
                writer.WriteNull();
                return;
            }

            writer.WriteStartArray();
            writer.WriteValue(coordinate.Longitude);
            writer.WriteValue(coordinate.Latitude);
            if (coordinate.Is3D || coordinate.IsMeasured)
                writer.WriteValue(((Is3D)coordinate).Elevation);
            if (coordinate.IsMeasured)
                writer.WriteValue(((IsMeasured)coordinate).Measure);
            writer.WriteEndArray();
        }
开发者ID:asapostolov,项目名称:Geo,代码行数:19,代码来源:CoordinateConverter.cs

示例15: WriteModelMetaData

 private void WriteModelMetaData(JsonWriter writer, Model.MetaData obj) {
     var t = obj.GetType();
     var properties = t.GetProperties();
     writer.WriteStartObject();
     foreach (var property in properties) {
         writer.WritePropertyName(property.Name);
         writer.WriteValue(property.GetValue(obj));
     }
     writer.WriteEndObject();
 }
开发者ID:anishpateluk,项目名称:shuriken,代码行数:10,代码来源:RavenDbModelJsonConverter.cs


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