-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathJsonDiffOptions.cs
72 lines (61 loc) · 2.82 KB
/
JsonDiffOptions.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
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text.Json.JsonDiffPatch.Diffs;
using System.Text.Json.Nodes;
namespace System.Text.Json.JsonDiffPatch
{
/// <summary>
/// Represents options for making JSON diff.
/// </summary>
public class JsonDiffOptions
{
private JsonElementComparison? _jsonElementComparison;
/// <summary>
/// Specifies whether to suppress detect array move. Default value is <c>false</c>.
/// </summary>
public bool SuppressDetectArrayMove { get; set; }
/// <summary>
/// Gets or sets custom function to match array items when array items are found not equal using default match
/// algorithm.
/// </summary>
public ArrayItemMatch? ArrayItemMatcher { get; set; }
/// <summary>
/// Gets or sets the function to find key of a <see cref="JsonObject"/> or <see cref="JsonArray"/>.
/// </summary>
public Func<JsonNode?, int, object?>? ArrayObjectItemKeyFinder { get; set; }
/// <summary>
/// Gets or sets whether two JSON objects (object or array) should be considered equal if they are at the same
/// index inside their parent arrays.
/// </summary>
public bool ArrayObjectItemMatchByPosition { get; set; }
/// <summary>
/// Gets or sets the minimum length of texts that should be compared using long text comparison algorithm, e.g.
/// <c>diff_match_patch</c> from Google. If this property is set to <c>0</c>, long text comparison algorithm is
/// disabled. Default value is <c>0</c>.
/// </summary>
public int TextDiffMinLength { get; set; }
/// <summary>
/// Gets or sets the function to diff long texts.
/// </summary>
public Func<string, string, string?>? TextDiffProvider { get; set; }
/// <summary>
/// Gets or sets the mode to compare two <see cref="JsonElement"/> instances.
/// </summary>
public JsonElementComparison JsonElementComparison
{
get => _jsonElementComparison ?? JsonDiffPatcher.DefaultComparison;
set => _jsonElementComparison = value;
}
/// <summary>
/// Gets or sets the <see cref="JsonValue"/> comparer.
/// </summary>
public IEqualityComparer<JsonValue>? ValueComparer { get; set; }
/// <summary>
/// Gets or sets the filter function to ignore JSON property. To ignore a property,
/// implement this function and return <c>false</c>.
/// </summary>
public Func<string, JsonDiffContext, bool>? PropertyFilter { get; set; }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal JsonComparerOptions CreateComparerOptions() => new(JsonElementComparison, ValueComparer);
}
}