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


C# JsonWriter.WritePropertyName方法代码示例

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


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

示例1: WriteJson

        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            var representation = value as Representation;
            if (representation != null)
                representation.RepopulateHyperMedia();

            var list = (IRepresentationList)value;

            writer.WriteStartObject();
            writer.WritePropertyName("_links");
            serializer.Serialize(writer, list.Links);

            writer.WritePropertyName("_embedded");
            writer.WriteStartObject();
            writer.WritePropertyName(list.Rel);
            writer.WriteStartArray();
            foreach (Representation halResource in list)
            {
                serializer.Serialize(writer, halResource);
            }

            writer.WriteEndArray();
            writer.WriteEndObject();

            var listType = list.GetType();
            var propertyInfos = typeof(RepresentationList<>).GetProperties().Select(p => p.Name);
            foreach (var property in listType.GetProperties().Where(p => !propertyInfos.Contains(p.Name)))
            {
                writer.WritePropertyName(property.Name.ToLower());
                serializer.Serialize(writer, property.GetValue(value, null));
            }

            writer.WriteEndObject();
        }
开发者ID:JoryUK,项目名称:WebApi.Hal,代码行数:34,代码来源:ResourceListConverter.cs

示例2: Write

        public void Write(JsonWriter writer)
        {
            Validate();

            writer.WriteStartObject();

            writer.WritePropertyName("key");
            writer.WriteValue(Key);

            if (!string.IsNullOrEmpty(ChangeMessage))
            {
                writer.WritePropertyName("changeMessage");
                writer.WriteValue(ChangeMessage);
            }

            if (!string.IsNullOrEmpty(Label))
            {
                writer.WritePropertyName("label");
                writer.WriteValue(Label);
            }

            if (TextAlignment != FieldTextAlignment.Unspecified)
            {
                writer.WritePropertyName("textAlignment");
                writer.WriteValue(TextAlignment);
            }

            WriteKeys(writer);

            writer.WritePropertyName("value");
            WriteValue(writer);

            writer.WriteEndObject();
        }
开发者ID:Harleyd210,项目名称:dotnet-passbook,代码行数:34,代码来源:Field.cs

示例3: WriteJson

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

            //{
            writer.WriteStartObject();

            // "DatasetInterval" : "1"
            writer.WritePropertyName("DatasetInterval");
            writer.WriteValue(heartActivitiesIntraday.DatasetInterval);

            // "DatasetType" : "SecondsHeartrate"
            writer.WritePropertyName("DatasetType");
            writer.WriteValue(heartActivitiesIntraday.DatasetType);

            writer.WritePropertyName("Dataset");
            writer.WriteStartArray();
            foreach (var datasetInverval in heartActivitiesIntraday.Dataset)
            {
                // "Time" : "2008-09-22T14:01:54.9571247Z"
                writer.WritePropertyName("Time");
                writer.WriteValue(datasetInverval.Time.ToString("o"));

                // "Value": 1
                writer.WritePropertyName("Value");
                writer.WriteValue(datasetInverval.Value);

            }
            writer.WriteEndArray();
            
            //}
            writer.WriteEndObject();

        }
开发者ID:lobrien,项目名称:Fitbit.NET,代码行数:34,代码来源:HeartActivitiesIntraday.cs

示例4: WriteJson

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

            list.Links.Add(new Link
            {
                Rel = "self",
                Href = list.Href
            });

            writer.WriteStartObject();
            writer.WritePropertyName("_links");
            serializer.Serialize(writer, list.Links);

            writer.WritePropertyName("_embedded");
            writer.WriteStartObject();
            writer.WritePropertyName(list.Rel);
            writer.WriteStartArray();
            foreach (HalResource halResource in (IEnumerable)value)
            {
                serializer.Serialize(writer, halResource);
            }
            writer.WriteEndArray();
            writer.WriteEndObject();
            writer.WriteEndObject();
        }
开发者ID:mabster,项目名称:WebApi.Hal,代码行数:26,代码来源:ResourceListConverter.cs

示例5: WriteJson

        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            if (value == null)
            {
                writer.WriteNull();
            }
            else
            {
                var notifications = (ClientNotifications)value;
                writer.WriteStartArray();

                foreach (var p in notifications)
                {
                    writer.WriteStartObject();
                    writer.WritePropertyName("id");
                    writer.WriteValue(p.Id.ToString("N"));
                    writer.WritePropertyName("message");
                    writer.WriteValue(p.Message);
                    writer.WritePropertyName("title");
                    writer.WriteValue(p.Title);
                    writer.WritePropertyName("type");
                    writer.WriteValue(p.Type.ToString().ToLower());
                    writer.WriteEndObject();
                }
                writer.WriteEndArray();
            }

        }
开发者ID:RebelCMS,项目名称:rebelcmsxu5,代码行数:28,代码来源:ClientNotificationsJsonConverter.cs

示例6: WriteJson

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

			var settings = serializer.GetConnectionSettings();
			var field = settings.Inferrer.Field(t.Field);

			writer.WriteStartObject();
			{
				if (t.Terms.HasAny())
				{
					writer.WritePropertyName(field);
					serializer.Serialize(writer, t.Terms);
				}
				else if (t.TermsLookup != null)
				{
					writer.WritePropertyName(field);
					serializer.Serialize(writer, t.TermsLookup);
				}
				if (t.Boost.HasValue)
				{
					writer.WritePropertyName("boost");
					writer.WriteValue(t.Boost.Value);
				}
				if (!t.Name.IsNullOrEmpty())
				{
					writer.WritePropertyName("_name");
					writer.WriteValue(t.Name);
				}
			}
			writer.WriteEndObject();
		}
开发者ID:c1sc0,项目名称:elasticsearch-net,代码行数:33,代码来源:TermsQueryJsonConverter.cs

示例7: Write

        public void Write(JsonWriter writer)
        {
            Validate();

            writer.WriteStartObject();

            writer.WritePropertyName("proximityUUID");
            writer.WriteValue(ProximityUUID);

            if (!string.IsNullOrEmpty(RelevantText))
            {
                writer.WritePropertyName("relevantText");
                writer.WriteValue(RelevantText);
            }

            if (Minor.HasValue)
            {
                writer.WritePropertyName("minor");
                writer.WriteValue(Minor);
            }

            if (Major.HasValue)
            {
                writer.WritePropertyName("major");
                writer.WriteValue(Major);
            }

            writer.WriteEndObject();
        }
开发者ID:joe-keane,项目名称:dotnet-passbook,代码行数:29,代码来源:RelevantBeacon.cs

示例8: WriteJson

        public override JsonWriter WriteJson(JsonWriter writer)
        {
            if(Filters.Count > 0)
            {
                writer.WritePropertyName("inputs");
                writer.WriteStartObject();

                writer.WritePropertyName("bucket");
                writer.WriteValue(_bucket);

                writer.WritePropertyName("key_filters");
                writer.WriteStartArray();

                Filters.ForEach(f => writer.WriteRawValue(f.ToJsonString()));

                writer.WriteEndArray();
                writer.WriteEndObject();
            }
            else
            {
                writer.WritePropertyName("inputs");
                writer.WriteValue(_bucket);
            }

            return writer;
        }
开发者ID:taliesins,项目名称:CorrugatedIron,代码行数:26,代码来源:RiakBucketInput.cs

示例9: WriteJson

        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            var model = value as LinkModel;
            if(model!=null)
            {
                writer.WriteStartObject();

                writer.WritePropertyName("href");
                writer.WriteValue(model.Href);

                writer.WritePropertyName("rel");
                writer.WriteValue(model.Rel);

                if(!model.Method.Equals("GET",StringComparison.OrdinalIgnoreCase))
                {
                    writer.WritePropertyName("method");
                    writer.WriteValue(model.Method);
                }

                if(model.IsTemplated)
                {
                    writer.WritePropertyName("isTemplated");
                    writer.WriteValue(model.IsTemplated);
                }

                writer.WriteEndObject();
            }
        }
开发者ID:nywebman,项目名称:WebApiFoodDiary,代码行数:28,代码来源:LinkModelConverter.cs

示例10: WriteJson

		public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
		{
			MatchAllQuery term = (MatchAllQuery)value;
			if (term != null)
			{
				writer.WriteStartObject();
				writer.WritePropertyName("match_all");
				writer.WriteStartObject();

				if (!string.IsNullOrEmpty(term.NormsField))
				{
					writer.WritePropertyName("norms_field");
					writer.WriteValue(term.NormsField);
				}

				if (term.Boost > 0)
				{
					writer.WritePropertyName("boost");
					writer.WriteValue(term.Boost);
				}

				writer.WriteEndObject();
				writer.WriteEndObject();
			}
		}
开发者ID:starckgates,项目名称:ElasticSearch.Net,代码行数:25,代码来源:MatchAllQueryConverter.cs

示例11: WriteJson

		public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
		{
			FieldQuery term = (FieldQuery)value;
			if (term != null)
			{
				writer.WriteStartObject();
				writer.WritePropertyName("field");
				writer.WriteStartObject();
				writer.WritePropertyName(term.Field);
				writer.WriteValue(term.QueryString);
				
				if(!term.Boost.Equals(default(float)))
				{
					writer.WritePropertyName("boost");
					writer.WriteValue(term.Boost);	
				}

				if (term.EnablePositionIncrements != default(bool))
				{
					writer.WritePropertyName("enable_position_increments");
					writer.WriteValue(term.EnablePositionIncrements.ToString().ToLower());
				}

				writer.WriteEndObject();
				writer.WriteEndObject();
			}
		}
开发者ID:starckgates,项目名称:ElasticSearch.Net,代码行数:27,代码来源:FieldQueryConverter.cs

示例12: WriteJson

        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            FeatureResult f = (FeatureResult)value;

            writer.WriteStartObject();

            if (f.Id != null){
                writer.WritePropertyName("id");
                writer.WriteValue(f.Id);
            }

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

            writer.WritePropertyName("type");
            serializer.Serialize(writer, (f.Type));

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

            writer.WriteEndObject();
        }
开发者ID:Terradue,项目名称:DotNetOpenSearchGeoJson,代码行数:26,代码来源:FeatureResultJsonConverter.cs

示例13: WriteJson

 public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
 {
     // value should be an entity or a collection of entities.
     var singleEntity = !(value is IEnumerable);
     writer.WriteStartObject();
     writer.WritePropertyName("@odata.context");
     writer.WriteValue(GenerateContextUrlString(value, singleEntity));
     if (!singleEntity)
     {
         writer.WritePropertyName("value");
         writer.WriteStartArray();
     }
     if (singleEntity)
     {
         WriteEntity(writer, value);
     }
     else
     {
         foreach (var o in (IEnumerable)value)
         {
             writer.WriteStartObject();
             WriteEntity(writer, o);
             writer.WriteEndObject();
         }
     }
     if (!singleEntity)
     {
         writer.WriteEndArray();
     }
     writer.WriteEndObject();
 }
开发者ID:ZhaoYngTest01,项目名称:WebApi,代码行数:31,代码来源:ODataJsonConverter.cs

示例14: WriteJson

        public override void WriteJson(JsonWriter writer, object value, Newtonsoft.Json.JsonSerializer serializer)
        {
            if(value == null)
            {
                writer.WriteNull();
                return;
            }

            MerkleNode mn = value as MerkleNode;

            writer.WriteStartObject();

            writer.WritePropertyName("Data");
            serializer.Serialize(writer, mn.Data);

            writer.WritePropertyName("Hash");
            serializer.Serialize(writer, mn.Hash);

            writer.WritePropertyName("Links");
            serializer.Serialize(writer, mn.Links);

            writer.WritePropertyName("Name");
            serializer.Serialize(writer, mn.Name);

            writer.WritePropertyName("Size");
            serializer.Serialize(writer, mn.Size);

            writer.WriteEndObject();
        }
开发者ID:TrekDev,项目名称:net-ipfs-api,代码行数:29,代码来源:MerkleNodeConverter.cs

示例15: WriteJson

        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            var links = (IList<Link>) value;
            writer.WriteStartObject();

            foreach (var link in links)
            {
                writer.WritePropertyName(link.Rel);
                writer.WriteStartObject();
                writer.WritePropertyName("href");
                writer.WriteValue(link.Href);

                if (link.IsTemplated)
                {
                    writer.WritePropertyName("isTemplated");
                    writer.WriteValue(true);
                }

                if (!string.IsNullOrWhiteSpace(link.Title))
                {
                    writer.WritePropertyName("title");
                    writer.WriteValue(link.Title);
                }
                

                writer.WriteEndObject();
            }
            writer.WriteEndObject();
        }
开发者ID:OndeVai,项目名称:WebApi.Hal,代码行数:29,代码来源:LinksConverter.cs


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