-
-
Notifications
You must be signed in to change notification settings - Fork 82
/
Copy pathJsonLdContext.cs
78 lines (66 loc) · 2.19 KB
/
JsonLdContext.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
namespace Schema.NET;
using System;
using System.Text.Json.Serialization;
/// <summary>
/// The @context for a JSON-LD document.
/// See https://w3c.github.io/json-ld-syntax
/// </summary>
public class JsonLdContext : IEquatable<JsonLdContext>
{
/// <summary>
/// Gets or sets the name.
/// </summary>
[JsonPropertyName("name")]
[JsonPropertyOrder(0)]
public string? Name { get; set; } = Constants.HttpsSchemaOrgUrl;
/// <summary>
/// Gets or sets the language.
/// </summary>
[JsonPropertyName("@language")]
[JsonPropertyOrder(1)]
public string? Language { get; set; }
/// <summary>
/// Performs an implicit conversion from <see cref="JsonLdContext"/> to <see cref="string"/>.
/// </summary>
/// <param name="context">The context.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator string?(JsonLdContext context) => context.Name;
/// <summary>
/// Implements the operator ==.
/// </summary>
/// <param name="left">The left.</param>
/// <param name="right">The right.</param>
/// <returns>
/// The result of the operator.
/// </returns>
public static bool operator ==(JsonLdContext left, JsonLdContext right) => left.Equals(right);
/// <summary>
/// Implements the operator !=.
/// </summary>
/// <param name="left">The left.</param>
/// <param name="right">The right.</param>
/// <returns>
/// The result of the operator.
/// </returns>
public static bool operator !=(JsonLdContext left, JsonLdContext right) => !(left == right);
/// <inheritdoc />
public bool Equals(JsonLdContext? other)
{
if (other is null)
{
return false;
}
if (ReferenceEquals(this, other))
{
return true;
}
return this.Name == other.Name &&
this.Language == other.Language;
}
/// <inheritdoc />
public override bool Equals(object? obj) => this.Equals(obj as JsonLdContext);
/// <inheritdoc />
public override int GetHashCode() => HashCode.Of(this.Name).And(this.Language);
/// <inheritdoc />
public override string? ToString() => this.Name;
}