Skip to content

Commit f14c0e3

Browse files
authored
Merge pull request #302 from Turnerj/pending-types
Create Schema.NET.Pending project for pending types
2 parents 351ceb2 + 7a9885e commit f14c0e3

28 files changed

+4373
-2679
lines changed

Schema.NET.sln

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,35 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{
9191
.github\workflows\release-drafter.yml = .github\workflows\release-drafter.yml
9292
EndProjectSection
9393
EndProject
94-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Schema.NET.Updater", "Tools\Schema.NET.Updater\Schema.NET.Updater.csproj", "{8923F9E2-4BB8-45F9-9A85-863F381B46EE}"
94+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Schema.NET.Pending", "Source\Schema.NET.Pending\Schema.NET.Pending.csproj", "{4EDF33FF-4532-4328-A158-D026C66537BA}"
95+
EndProject
96+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{AF228B8A-7290-4E26-8506-934C290C6AE3}"
97+
ProjectSection(SolutionItems) = preProject
98+
Source\Common\ContactType.cs = Source\Common\ContactType.cs
99+
Source\Common\ContextJsonConverter.cs = Source\Common\ContextJsonConverter.cs
100+
Source\Common\DateTimeHelper.cs = Source\Common\DateTimeHelper.cs
101+
Source\Common\DateTimeToIso8601DateValuesJsonConverter.cs = Source\Common\DateTimeToIso8601DateValuesJsonConverter.cs
102+
Source\Common\EnumHelper.cs = Source\Common\EnumHelper.cs
103+
Source\Common\FastActivator.cs = Source\Common\FastActivator.cs
104+
Source\Common\HashCode.cs = Source\Common\HashCode.cs
105+
Source\Common\IValues.cs = Source\Common\IValues.cs
106+
Source\Common\JsonLdContext.cs = Source\Common\JsonLdContext.cs
107+
Source\Common\JsonLdObject.cs = Source\Common\JsonLdObject.cs
108+
Source\Common\OneOrMany{T}.cs = Source\Common\OneOrMany{T}.cs
109+
Source\Common\PropertyValueSpecification.Partial.cs = Source\Common\PropertyValueSpecification.Partial.cs
110+
Source\Common\SchemaSerializer.cs = Source\Common\SchemaSerializer.cs
111+
Source\Common\Thing.Partial.cs = Source\Common\Thing.Partial.cs
112+
Source\Common\TimeSpanToISO8601DurationValuesJsonConverter.cs = Source\Common\TimeSpanToISO8601DurationValuesJsonConverter.cs
113+
Source\Common\TypeExtensions.cs = Source\Common\TypeExtensions.cs
114+
Source\Common\ValuesJsonConverter.cs = Source\Common\ValuesJsonConverter.cs
115+
Source\Common\Values{T1,T2,T3,T4,T5,T6,T7}.cs = Source\Common\Values{T1,T2,T3,T4,T5,T6,T7}.cs
116+
Source\Common\Values{T1,T2,T3,T4,T5,T6}.cs = Source\Common\Values{T1,T2,T3,T4,T5,T6}.cs
117+
Source\Common\Values{T1,T2,T3,T4}.cs = Source\Common\Values{T1,T2,T3,T4}.cs
118+
Source\Common\Values{T1,T2,T3}.cs = Source\Common\Values{T1,T2,T3}.cs
119+
Source\Common\Values{T1,T2}.cs = Source\Common\Values{T1,T2}.cs
120+
EndProjectSection
121+
EndProject
122+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Schema.NET.Updater", "Tools\Schema.NET.Updater\Schema.NET.Updater.csproj", "{8923F9E2-4BB8-45F9-9A85-863F381B46EE}"
95123
EndProject
96124
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Data", "Data", "{A208CE34-D2DF-4BD2-B6CF-3047883BC820}"
97125
ProjectSection(SolutionItems) = preProject
@@ -120,6 +148,10 @@ Global
120148
{379FE111-579B-4A3A-9E49-40D8E2904883}.Debug|Any CPU.Build.0 = Debug|Any CPU
121149
{379FE111-579B-4A3A-9E49-40D8E2904883}.Release|Any CPU.ActiveCfg = Release|Any CPU
122150
{379FE111-579B-4A3A-9E49-40D8E2904883}.Release|Any CPU.Build.0 = Release|Any CPU
151+
{4EDF33FF-4532-4328-A158-D026C66537BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
152+
{4EDF33FF-4532-4328-A158-D026C66537BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
153+
{4EDF33FF-4532-4328-A158-D026C66537BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
154+
{4EDF33FF-4532-4328-A158-D026C66537BA}.Release|Any CPU.Build.0 = Release|Any CPU
123155
{8923F9E2-4BB8-45F9-9A85-863F381B46EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
124156
{8923F9E2-4BB8-45F9-9A85-863F381B46EE}.Debug|Any CPU.Build.0 = Debug|Any CPU
125157
{8923F9E2-4BB8-45F9-9A85-863F381B46EE}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -137,6 +169,8 @@ Global
137169
{379FE111-579B-4A3A-9E49-40D8E2904883} = {1D81D082-9C25-4D4E-890E-9CD173532307}
138170
{040F8F6D-9144-42FD-9B0D-7F88EF0C26C5} = {F20E2797-D1E3-4321-91BB-FAE54954D2A0}
139171
{9444439E-8476-4BAB-AE1E-DBC24B58865F} = {040F8F6D-9144-42FD-9B0D-7F88EF0C26C5}
172+
{4EDF33FF-4532-4328-A158-D026C66537BA} = {719809C2-A551-4C4A-9EFD-B10FB5E35BC0}
173+
{AF228B8A-7290-4E26-8506-934C290C6AE3} = {719809C2-A551-4C4A-9EFD-B10FB5E35BC0}
140174
{8923F9E2-4BB8-45F9-9A85-863F381B46EE} = {1D81D082-9C25-4D4E-890E-9CD173532307}
141175
EndGlobalSection
142176
GlobalSection(ExtensibilityGlobals) = postSolution
File renamed without changes.
Lines changed: 89 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,89 @@
1-
namespace Schema.NET
2-
{
3-
using System;
4-
using Newtonsoft.Json;
5-
using Newtonsoft.Json.Linq;
6-
7-
/// <summary>
8-
/// Converts a <see cref="JsonLdContext"/> object to and from JSON.
9-
/// </summary>
10-
/// <seealso cref="JsonConverter" />
11-
public class ContextJsonConverter : JsonConverter<JsonLdContext>
12-
{
13-
/// <inheritdoc />
14-
public override JsonLdContext ReadJson(JsonReader reader, Type objectType, JsonLdContext? existingValue, bool hasExistingValue, JsonSerializer serializer)
15-
{
16-
if (reader is null)
17-
{
18-
throw new ArgumentNullException(nameof(reader));
19-
}
20-
21-
if (objectType is null)
22-
{
23-
throw new ArgumentNullException(nameof(objectType));
24-
}
25-
26-
if (serializer is null)
27-
{
28-
throw new ArgumentNullException(nameof(serializer));
29-
}
30-
31-
var context = hasExistingValue ? existingValue! : new JsonLdContext();
32-
33-
string? name;
34-
string? language;
35-
if (reader.TokenType == JsonToken.String)
36-
{
37-
name = (string?)reader.Value;
38-
language = null;
39-
}
40-
else
41-
{
42-
var o = JObject.Load(reader);
43-
44-
var nameProperty = o.Property("name", StringComparison.OrdinalIgnoreCase);
45-
name = nameProperty?.Value?.ToString() ?? "https://schema.org";
46-
47-
var languageProperty = o.Property("@language", StringComparison.OrdinalIgnoreCase);
48-
language = languageProperty?.Value?.ToString();
49-
}
50-
51-
context.Name = name;
52-
context.Language = language;
53-
return context;
54-
}
55-
56-
/// <inheritdoc />
57-
public override void WriteJson(JsonWriter writer, JsonLdContext? value, JsonSerializer serializer)
58-
{
59-
if (writer is null)
60-
{
61-
throw new ArgumentNullException(nameof(writer));
62-
}
63-
64-
if (value is null)
65-
{
66-
throw new ArgumentNullException(nameof(value));
67-
}
68-
69-
if (serializer is null)
70-
{
71-
throw new ArgumentNullException(nameof(serializer));
72-
}
73-
74-
if (string.IsNullOrWhiteSpace(value.Language))
75-
{
76-
writer.WriteValue(value.Name);
77-
}
78-
else
79-
{
80-
writer.WriteStartObject();
81-
writer.WritePropertyName("name");
82-
writer.WriteValue(value.Name);
83-
writer.WritePropertyName("@language");
84-
writer.WriteValue(value.Language);
85-
writer.WriteEndObject();
86-
}
87-
}
88-
}
89-
}
1+
namespace Schema.NET
2+
{
3+
using System;
4+
using Newtonsoft.Json;
5+
using Newtonsoft.Json.Linq;
6+
7+
/// <summary>
8+
/// Converts a <see cref="JsonLdContext"/> object to and from JSON.
9+
/// </summary>
10+
/// <seealso cref="JsonConverter" />
11+
public class ContextJsonConverter : JsonConverter<JsonLdContext>
12+
{
13+
/// <inheritdoc />
14+
public override JsonLdContext ReadJson(JsonReader reader, Type objectType, JsonLdContext? existingValue, bool hasExistingValue, JsonSerializer serializer)
15+
{
16+
if (reader is null)
17+
{
18+
throw new ArgumentNullException(nameof(reader));
19+
}
20+
21+
if (objectType is null)
22+
{
23+
throw new ArgumentNullException(nameof(objectType));
24+
}
25+
26+
if (serializer is null)
27+
{
28+
throw new ArgumentNullException(nameof(serializer));
29+
}
30+
31+
var context = hasExistingValue ? existingValue! : new JsonLdContext();
32+
33+
string? name;
34+
string? language;
35+
if (reader.TokenType == JsonToken.String)
36+
{
37+
name = (string?)reader.Value;
38+
language = null;
39+
}
40+
else
41+
{
42+
var o = JObject.Load(reader);
43+
44+
var nameProperty = o.Property("name", StringComparison.OrdinalIgnoreCase);
45+
name = nameProperty?.Value?.ToString() ?? "https://schema.org";
46+
47+
var languageProperty = o.Property("@language", StringComparison.OrdinalIgnoreCase);
48+
language = languageProperty?.Value?.ToString();
49+
}
50+
51+
context.Name = name;
52+
context.Language = language;
53+
return context;
54+
}
55+
56+
/// <inheritdoc />
57+
public override void WriteJson(JsonWriter writer, JsonLdContext? value, JsonSerializer serializer)
58+
{
59+
if (writer is null)
60+
{
61+
throw new ArgumentNullException(nameof(writer));
62+
}
63+
64+
if (value is null)
65+
{
66+
throw new ArgumentNullException(nameof(value));
67+
}
68+
69+
if (serializer is null)
70+
{
71+
throw new ArgumentNullException(nameof(serializer));
72+
}
73+
74+
if (string.IsNullOrWhiteSpace(value.Language))
75+
{
76+
writer.WriteValue(value.Name);
77+
}
78+
else
79+
{
80+
writer.WriteStartObject();
81+
writer.WritePropertyName("name");
82+
writer.WriteValue(value.Name);
83+
writer.WritePropertyName("@language");
84+
writer.WriteValue(value.Language);
85+
writer.WriteEndObject();
86+
}
87+
}
88+
}
89+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)