-
Notifications
You must be signed in to change notification settings - Fork 533
Expand file tree
/
Copy pathFullTextPath.cs
More file actions
77 lines (70 loc) · 2.52 KB
/
FullTextPath.cs
File metadata and controls
77 lines (70 loc) · 2.52 KB
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
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace Microsoft.Azure.Cosmos
{
using System;
using System.Collections.Generic;
using Microsoft.Azure.Documents;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
/// <summary>
/// DOM for a full text path. A full text path is defined at the collection level.
/// </summary>
/// <example>
/// <![CDATA[
/// "fullTextPolicy":
/// {
/// "defaultLanguage": "en-US"
/// "fullTextPaths": [
/// {
/// "path": "/text1"
/// "language": "1033"
/// },
/// {
/// "path": "/text2"
/// "language": "en-US",
/// }
/// ]
/// }
/// ]]>
/// </example>
public class FullTextPath : IEquatable<FullTextPath>
{
/// <summary>
/// Gets or sets a string containing the path of the full text index.
/// </summary>
[JsonProperty(PropertyName = Constants.Properties.Path)]
public string Path { get; set; }
/// <summary>
/// Gets or sets a string containing the language of the full text path.
/// </summary>
[JsonProperty(PropertyName = "language", NullValueHandling = NullValueHandling.Ignore)]
public string Language { get; set; }
/// <summary>
/// This contains additional values for scenarios where the SDK is not aware of new fields.
/// This ensures that if resource is read and updated none of the fields will be lost in the process.
/// </summary>
[JsonExtensionData]
internal IDictionary<string, JToken> AdditionalProperties { get; private set; }
/// <summary>
/// Ensures that the paths specified in the full text policy are valid.
/// </summary>
public void ValidateFullTextPath()
{
if (string.IsNullOrEmpty(this.Path))
{
throw new ArgumentException("Argument {0} can't be null or empty.", nameof(this.Path));
}
if (this.Path[0] != '/')
{
throw new ArgumentException("The argument {0} is not a valid path.", this.Path);
}
}
/// <inheritdoc/>
public bool Equals(FullTextPath that)
{
return this.Path.Equals(that.Path) && this.Language.Equals(that.Language);
}
}
}