-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
SynonymMap.cs
74 lines (64 loc) · 3 KB
/
SynonymMap.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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System;
using System.IO;
using Azure.Core;
// suppress the generated type for the property `Format`
[assembly: CodeGenSuppressType("SynonymMapFormat")]
namespace Azure.Search.Documents.Indexes.Models
{
[CodeGenSuppress(nameof(SynonymMap), typeof(string), typeof(string))]
public partial class SynonymMap
{
private const string DefaultFormat = "solr";
[CodeGenMember("ETag")]
private string _etag;
// TODO: Replace constructor and read-only properties when https://github.com/Azure/autorest.csharp/issues/554 is fixed.
/// <summary>
/// Initializes a new instance of the <see cref="SynonymMap"/> class.
/// </summary>
/// <param name="name">The name of the synonym map.</param>
/// <param name="synonyms">
/// The formatted synonyms string to define.
/// Because only the "solr" synonym map format is currently supported, these are values delimited by "\n".
/// </param>
/// <exception cref="ArgumentException"><paramref name="name"/> or <paramref name="synonyms"/> is an empty string.</exception>
/// <exception cref="ArgumentNullException"><paramref name="name"/> or <paramref name="synonyms"/> is null.</exception>
public SynonymMap(string name, string synonyms)
{
Argument.AssertNotNullOrEmpty(name, nameof(name));
Argument.AssertNotNullOrEmpty(synonyms, nameof(synonyms));
Name = name;
Format = DefaultFormat;
Synonyms = synonyms;
}
/// <summary>
/// Initializes a new instance of the <see cref="SynonymMap"/> class.
/// </summary>
/// <param name="name">The name of the synonym map.</param>
/// <param name="reader">
/// A <see cref="TextReader"/> from which formatted synonyms are read.
/// Because only the "solr" synonym map format is currently supported, these are values delimited by "\n".
/// </param>
/// <exception cref="ArgumentException"><paramref name="name"/> is an empty string.</exception>
/// <exception cref="ArgumentNullException"><paramref name="name"/> or <paramref name="reader"/> is null.</exception>
public SynonymMap(string name, TextReader reader)
{
Argument.AssertNotNullOrEmpty(name, nameof(name));
Argument.AssertNotNull(reader, nameof(reader));
Name = name;
Format = DefaultFormat;
Synonyms = reader.ReadToEnd();
}
/// <summary>
/// The <see cref="Azure.ETag"/> of the <see cref="SynonymMap"/>.
/// </summary>
public ETag? ETag
{
get => _etag is null ? (ETag?)null : new ETag(_etag);
set => _etag = value?.ToString();
}
/// <summary> The format of the synonym map. Only the "solr" format is currently supported. </summary>
internal string Format { get; set; }
}
}