Skip to content

Commit b86bfbf

Browse files
committed
no message
1 parent b96c885 commit b86bfbf

File tree

81 files changed

+358
-166
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+358
-166
lines changed

Source/Schema.NET/ValuesJsonConverter.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
namespace Schema.NET
22
{
33
using System;
4+
using System.Collections;
45
using System.Collections.Generic;
56
using System.Diagnostics;
67
using System.Globalization;
@@ -66,13 +67,18 @@ public override object ReadJson(
6667
if (tokenType == JsonToken.StartArray)
6768
{
6869
var items = new List<object>();
69-
foreach (var type in mainType.GenericTypeArguments)
70+
for (var i = mainType.GenericTypeArguments.Length - 1; i >= 0; i--)
7071
{
72+
var type = mainType.GenericTypeArguments[i];
7173
var unwrappedType = type.GetUnderlyingTypeFromNullable();
7274
var args = ReadJsonArray(token, unwrappedType);
73-
var genericType = typeof(OneOrMany<>).MakeGenericType(type);
74-
var item = (IValues)Activator.CreateInstance(genericType, args);
75-
items.Add(item);
75+
76+
if (args != null && args.Count > 0)
77+
{
78+
var genericType = typeof(OneOrMany<>).MakeGenericType(type);
79+
var item = (IValues)Activator.CreateInstance(genericType, args);
80+
items.Add(item);
81+
}
7682
}
7783

7884
argument = items;
@@ -390,7 +396,7 @@ private static Type ToClass(Type type)
390396
return type;
391397
}
392398

393-
private static object ReadJsonArray(JToken token, Type type)
399+
private static IList ReadJsonArray(JToken token, Type type)
394400
{
395401
var classType = ToClass(type);
396402
var listType = typeof(List<>).MakeGenericType(classType);
@@ -419,7 +425,7 @@ private static object ReadJsonArray(JToken token, Type type)
419425
}
420426
}
421427

422-
return list;
428+
return (IList)list;
423429
}
424430

425431
private static IEnumerable<Type> GetTypeHierarchy(Type type)

Source/Schema.NET/core/ItemList.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace Schema.NET
1+
namespace Schema.NET
22
{
33
using System;
44
using System.Runtime.Serialization;
@@ -14,7 +14,7 @@ public partial interface IItemList : IIntangible
1414
/// Text values are best if the elements in the list are plain strings. Existing entities are best for a simple, unordered list of existing things in your data. ListItem is used with ordered lists when you want to provide additional context about the element in that list or when the same item might be in different places in different lists.&lt;br/&gt;&lt;br/&gt;
1515
/// Note: The order of elements in your mark-up is not sufficient for indicating the order or elements. Use ListItem with a 'position' property in such cases.
1616
/// </summary>
17-
Values<IListItem, string, IThing>? ItemListElement { get; set; }
17+
Values<IThing, string, IListItem>? ItemListElement { get; set; }
1818

1919
/// <summary>
2020
/// Type of ordering (e.g. Ascending, Descending, Unordered).
@@ -46,7 +46,7 @@ public partial class ItemList : Intangible, IItemList
4646
/// </summary>
4747
[DataMember(Name = "itemListElement", Order = 206)]
4848
[JsonConverter(typeof(ValuesJsonConverter))]
49-
public Values<IListItem, string, IThing>? ItemListElement { get; set; }
49+
public Values<IThing, string, IListItem>? ItemListElement { get; set; }
5050

5151
/// <summary>
5252
/// Type of ordering (e.g. Ascending, Descending, Unordered).

Source/Schema.NET/core/combined/CreativeWorkAndItemListAndListItem.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace Schema.NET
1+
namespace Schema.NET
22
{
33
using System;
44
using System.Runtime.Serialization;
@@ -389,7 +389,7 @@ public abstract partial class CreativeWorkAndItemListAndListItem : Intangible, I
389389
/// </summary>
390390
[DataMember(Name = "itemListElement", Order = 257)]
391391
[JsonConverter(typeof(ValuesJsonConverter))]
392-
public Values<IListItem, string, IThing>? ItemListElement { get; set; }
392+
public Values<IThing, string, IListItem>? ItemListElement { get; set; }
393393

394394
/// <summary>
395395
/// Type of ordering (e.g. Ascending, Descending, Unordered).

Source/Schema.NET/core/enumerations/ActionStatusType.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
namespace Schema.NET
1+
namespace Schema.NET
22
{
33
using System.Runtime.Serialization;
4+
using Newtonsoft.Json;
5+
using Newtonsoft.Json.Converters;
46

57
/// <summary>
68
/// The status of an Action.
79
/// </summary>
10+
[JsonConverter(typeof(StringEnumConverter))]
811
public enum ActionStatusType
912
{
1013
/// <summary>

Source/Schema.NET/core/enumerations/BedType.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
namespace Schema.NET
1+
namespace Schema.NET
22
{
33
using System.Runtime.Serialization;
4+
using Newtonsoft.Json;
5+
using Newtonsoft.Json.Converters;
46

57
/// <summary>
68
/// A type of bed. This is used for indicating the bed or beds available in an accommodation.
79
/// </summary>
10+
[JsonConverter(typeof(StringEnumConverter))]
811
public enum BedType
912
{
1013
}

Source/Schema.NET/core/enumerations/BoardingPolicyType.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
namespace Schema.NET
1+
namespace Schema.NET
22
{
33
using System.Runtime.Serialization;
4+
using Newtonsoft.Json;
5+
using Newtonsoft.Json.Converters;
46

57
/// <summary>
68
/// A type of boarding policy used by an airline.
79
/// </summary>
10+
[JsonConverter(typeof(StringEnumConverter))]
811
public enum BoardingPolicyType
912
{
1013
/// <summary>

Source/Schema.NET/core/enumerations/BookFormatType.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
namespace Schema.NET
1+
namespace Schema.NET
22
{
33
using System.Runtime.Serialization;
4+
using Newtonsoft.Json;
5+
using Newtonsoft.Json.Converters;
46

57
/// <summary>
68
/// The publication format of the book.
79
/// </summary>
10+
[JsonConverter(typeof(StringEnumConverter))]
811
public enum BookFormatType
912
{
1013
/// <summary>

Source/Schema.NET/core/enumerations/BusinessEntityType.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
namespace Schema.NET
1+
namespace Schema.NET
22
{
33
using System.Runtime.Serialization;
4+
using Newtonsoft.Json;
5+
using Newtonsoft.Json.Converters;
46

57
/// <summary>
68
/// A business entity type is a conceptual entity representing the legal form, the size, the main line of business, the position in the value chain, or any combination thereof, of an organization or business person.&lt;br/&gt;&lt;br/&gt;
@@ -12,6 +14,7 @@
1214
/// &lt;li&gt;http://purl.org/goodrelations/v1#Reseller&lt;/li&gt;
1315
/// &lt;/ul&gt;
1416
/// </summary>
17+
[JsonConverter(typeof(StringEnumConverter))]
1518
public enum BusinessEntityType
1619
{
1720
}

Source/Schema.NET/core/enumerations/BusinessFunction.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
namespace Schema.NET
1+
namespace Schema.NET
22
{
33
using System.Runtime.Serialization;
4+
using Newtonsoft.Json;
5+
using Newtonsoft.Json.Converters;
46

57
/// <summary>
68
/// The business function specifies the type of activity or access (i.e., the bundle of rights) offered by the organization or business person through the offer. Typical are sell, rental or lease, maintenance or repair, manufacture / produce, recycle / dispose, engineering / construction, or installation. Proprietary specifications of access rights are also instances of this class.&lt;br/&gt;&lt;br/&gt;
@@ -16,6 +18,7 @@
1618
/// &lt;li&gt;http://purl.org/goodrelations/v1#Buy&lt;/li&gt;
1719
/// &lt;/ul&gt;
1820
/// </summary>
21+
[JsonConverter(typeof(StringEnumConverter))]
1922
public enum BusinessFunction
2023
{
2124
}

Source/Schema.NET/core/enumerations/ContactPointOption.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
namespace Schema.NET
1+
namespace Schema.NET
22
{
33
using System.Runtime.Serialization;
4+
using Newtonsoft.Json;
5+
using Newtonsoft.Json.Converters;
46

57
/// <summary>
68
/// Enumerated options related to a ContactPoint.
79
/// </summary>
10+
[JsonConverter(typeof(StringEnumConverter))]
811
public enum ContactPointOption
912
{
1013
/// <summary>

0 commit comments

Comments
 (0)