當前位置: 首頁>>代碼示例>>C#>>正文


C# JsonWriter.WriteEndArray方法代碼示例

本文整理匯總了C#中Newtonsoft.Json.JsonWriter.WriteEndArray方法的典型用法代碼示例。如果您正苦於以下問題:C# JsonWriter.WriteEndArray方法的具體用法?C# JsonWriter.WriteEndArray怎麽用?C# JsonWriter.WriteEndArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Newtonsoft.Json.JsonWriter的用法示例。


在下文中一共展示了JsonWriter.WriteEndArray方法的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: WriteJson

		public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
		{
			var marker = value as Indices;
			if (marker == null)
			{
				writer.WriteNull();
				return;
			}
			marker.Match(
				all =>
				{
					writer.WriteStartArray();
					writer.WriteValue("_all");
					writer.WriteEndArray();
				},
				many =>
				{
					var settings = serializer.GetConnectionSettings();
					writer.WriteStartArray();
					foreach (var m in many.Indices.Cast<IUrlParameter>())
						writer.WriteValue(m.GetString(settings));
					writer.WriteEndArray();
				}
			);
		}
開發者ID:c1sc0,項目名稱:elasticsearch-net,代碼行數:25,代碼來源:IndicesJsonConverter.cs

示例3: FormatJson

        public void FormatJson(ref JsonWriter writer)
        {
            writer.WriteStartObject();

            writer.WritePropertyName("type");
            writer.WriteValue("table");

            writer.WritePropertyName("headers");
            writer.WriteStartArray();
            foreach(var header in this.headers.ToArray())
            {
                writer.WriteValue(header);
            }
            writer.WriteEndArray();

            writer.WritePropertyName("rows");
            writer.WriteStartArray();
            foreach (var row in this.rows.ToArray())
            {
                writer.WriteStartArray();

                foreach( var field in row)
                {
                    writer.WriteValue(field);
                }

                writer.WriteEndArray();
            }
            writer.WriteEndArray();

            writer.WriteEndObject();
        }
開發者ID:BrixIT,項目名稱:CRT-Client,代碼行數:32,代碼來源:Table.cs

示例4: WriteJson

		public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
		{
			BoolQuery term = (BoolQuery)value;
			if (term != null)
			{
				writer.WriteStartObject();
				writer.WritePropertyName("bool");
				writer.WriteStartObject();
				bool pre = false;
				if(term.MustQueries!=null&&term.MustQueries.Count>0)
				{
					writer.WritePropertyName("must");
					writer.WriteStartArray();
					foreach (var VARIABLE in term.MustQueries)
					{
						serializer.Serialize(writer, VARIABLE);
					}
					writer.WriteEndArray();
				}
				if (term.MustNotQueries != null&&term.MustNotQueries.Count>0)
				{
					writer.WritePropertyName("must_not");
					writer.WriteStartArray();
					foreach (var VARIABLE in term.MustNotQueries)
					{
						serializer.Serialize(writer, VARIABLE);
					}
					writer.WriteEndArray();
				}
				if (term.ShouldQueries !=null&& term.ShouldQueries.Count > 0)
				{
					writer.WritePropertyName("should");
					writer.WriteStartArray();
					foreach (var shouldQuery in term.ShouldQueries)
					{
						serializer.Serialize(writer,shouldQuery);
					}
					writer.WriteEndArray();
				}
				if (Math.Abs(term.Boost - 1.0) > 0)
				{
					writer.WritePropertyName("boost");
					writer.WriteValue(term.Boost);
				}
				if (term.DisableCoord)
				{
					writer.WritePropertyName("disable_coord");
					writer.WriteValue(term.DisableCoord);
				}
				if (term.MinimumNumberShouldMatch != 1)
				{
					writer.WritePropertyName("minimum_number_should_match");
					writer.WriteValue(term.MinimumNumberShouldMatch);
				}
				writer.WriteEndObject();
				writer.WriteEndObject();
			}
		}
開發者ID:starckgates,項目名稱:ElasticSearch.Net,代碼行數:58,代碼來源:BoolQueryConverter.cs

示例5: WriteJson

        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            var rt = (ResultTable)value;
            
            writer.WriteStartObject();

            writer.WritePropertyName("entityColumn");
            writer.WriteValue(rt.EntityColumn?.Name);

            writer.WritePropertyName("columns");
            serializer.Serialize(writer, rt.Columns.Select(c => c.Column.Token.FullKey()).ToList());

            writer.WritePropertyName("pagination");
            serializer.Serialize(writer, new PaginationTS(rt.Pagination));

            writer.WritePropertyName("totalElements");
            writer.WriteValue(rt.TotalElements);


            writer.WritePropertyName("rows");
            writer.WriteStartArray();
            foreach (var row in rt.Rows)
            {
                writer.WriteStartObject();
                if (rt.EntityColumn != null)
                {
                    writer.WritePropertyName("entity");
                    serializer.Serialize(writer, row.Entity);
                }

                writer.WritePropertyName("columns");
                writer.WriteStartArray();
                foreach (var column in rt.Columns)
                {
                    using (JsonSerializerExtensions.SetCurrentPropertyRoute(column.Column.Token.GetPropertyRoute()))
                    {
                        serializer.Serialize(writer, row[column]);
                    }
                }
                writer.WriteEndArray();


                writer.WriteEndObject();

            }
            writer.WriteEndArray();


            writer.WriteEndObject();
        }
開發者ID:signumsoftware,項目名稱:framework,代碼行數:50,代碼來源:ResultTableConverter.cs

示例6: WriteJson

 public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
 {
     var extent = (Extent)value;
     writer.WriteStartArray();
     writer.WriteStartArray();
     writer.WriteValue(extent.X1);
     writer.WriteValue(extent.Y1);
     writer.WriteEndArray();
     writer.WriteStartArray();
     writer.WriteValue(extent.X2);
     writer.WriteValue(extent.Y2);
     writer.WriteEndArray();
     writer.WriteEndArray();
 }
開發者ID:jcarrascal,項目名稱:GisGlue,代碼行數:14,代碼來源:ExtentConverter.cs

示例7: WriteJson

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

            writer.WriteStartArray();

            if (list == null || list.Count == 0)
            {
                foreach (var item in list)
                {
                    writer.WriteStartObject();
                    if (value != null)
                    {
                        var type = value.GetType();
                        var name = type.Name;
                        var attribute = type.GetCustomAttributes(typeof(JsonWrapPropertyAttribute), true).FirstOrDefault() as JsonWrapPropertyAttribute;
                        if (attribute != null)
                        {
                            name = attribute.WrapName;
                        }

                        writer.WritePropertyName(name);
                        serializer.Serialize(writer, value);

                    }
                    writer.WriteEndObject();
                }
            }
            writer.WriteEndArray();
        }
開發者ID:vshlos,項目名稱:elasticsearch-sharp,代碼行數:30,代碼來源:ListObjectWrapConverter.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 links = new HashSet<Link>((IList<Link>)value, Link.EqualityComparer);
            var lookup = links.ToLookup(l => l.Rel);
            
            if (lookup.Count == 0) 
                return;

            writer.WriteStartObject();

            foreach (var rel in lookup)
            {
                var count = rel.Count();

                writer.WritePropertyName(rel.Key);
                
                if ((count > 1) || (rel.Key == Link.RelForCuries))
                    writer.WriteStartArray();

                foreach (var link in rel)
                    WriteLink(writer, link);

                if ((count > 1) || (rel.Key == Link.RelForCuries))
                    writer.WriteEndArray();
            }

            writer.WriteEndObject();
        }
開發者ID:iremezoff,項目名稱:AspNet.Hal,代碼行數:28,代碼來源:LinksConverter.cs

示例10: WriteJson

        /// <summary>
        /// Writes the Object to JSON
        /// </summary>
        /// <param name="writer">A JSON Writer object</param>
        /// <param name="value">Object to be converted</param>
        /// <param name="serializer">JSON Serializer object instance</param>
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            // We need a custom writer for char arrays, such as are used with SendKeys.
            // JSON.NET does not properly handle converting unicode characters to \uxxxx.
            writer.WriteStartArray();
            char[] arrayObject = value as char[];
            if (arrayObject != null)
            {
                foreach (char currentChar in arrayObject)
                {
                    int codepoint = Convert.ToInt32(currentChar);
                    if ((codepoint >= 32) && (codepoint <= 126))
                    {
                        writer.WriteValue(currentChar);
                    }
                    else
                    {
                        string charRepresentation = "\\u" + Convert.ToString(codepoint, 16).PadLeft(4, '0');
                        writer.WriteRawValue("\"" + charRepresentation + "\"");
                    }
                }
            }

            writer.WriteEndArray();
        }
開發者ID:zerodiv,項目名稱:CTM-Windows-Agent,代碼行數:31,代碼來源:CharArrayJsonConverter.cs

示例11: WriteJson

        public override void WriteJson(JsonWriter __writer, object __value, JsonSerializer __serializer)
        {
            var __對象 = (M接收事件)__value;
            __writer.WriteStartObject();
            __writer.WritePropertyName("對象名稱");
            __writer.WriteValue(__對象.對象名稱);
            __writer.WritePropertyName("事件名稱");
            __writer.WriteValue(__對象.事件名稱);
            __writer.WritePropertyName("實參列表");
            __writer.WriteStartArray();
            if (__對象.實參列表 != null)
            {
                foreach (var __kv in __對象.實參列表)
                {
                    __writer.WriteStartObject();
                    __writer.WritePropertyName("名稱");
                    __writer.WriteValue(__kv.名稱);
                    __writer.WritePropertyName("值");

                    if (__kv.值.TrimStart().StartsWith("{") || __kv.值.TrimStart().StartsWith("["))
                    {
                        __writer.WriteRawValue(__kv.值);
                    }
                    else
                    {
                        __writer.WriteValue(__kv.值);
                    }
                    __writer.WriteEndObject();
                }
            }
            __writer.WriteEndArray();
            __writer.WriteEndObject();
        }
開發者ID:xiaomiwk,項目名稱:K_tongyongfangwen,代碼行數:33,代碼來源:M接收事件Converter.cs

示例12: 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

示例13: 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

示例14: WriteJsonCoordinatesEnumerable

 protected void WriteJsonCoordinatesEnumerable(JsonWriter writer, IEnumerable<Coordinate[]> coordinates, JsonSerializer serializer)
 {
     writer.WriteStartArray();
     foreach (Coordinate[] coordinate in coordinates)
         WriteJsonCoordinates(writer, coordinate, serializer);
     writer.WriteEndArray();
 }
開發者ID:jaundice,項目名稱:NetTopologySuite,代碼行數:7,代碼來源:CoordinateConverters.cs

示例15: writeErrors

        private void writeErrors(ExecutionErrors errors, JsonWriter writer, JsonSerializer serializer)
        {
            if (errors == null || errors.Count == 0)
            {
                return;
            }

            writer.WritePropertyName("errors");

            writer.WriteStartArray();

            errors.Apply(error =>
            {
                writer.WriteStartObject();

                writer.WritePropertyName("message");
                serializer.Serialize(writer, error.Message);

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

                writer.WriteEndObject();
            });

            writer.WriteEndArray();
        }
開發者ID:graphql-dotnet,項目名稱:graphql-dotnet,代碼行數:29,代碼來源:ExecutionResultJsonConverter.cs


注:本文中的Newtonsoft.Json.JsonWriter.WriteEndArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。