| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using System.IO; |
| | 6 | | using Azure.Core; |
| | 7 | |
|
| | 8 | | namespace Azure.Search.Documents.Indexes.Models |
| | 9 | | { |
| | 10 | | [CodeGenSuppress(nameof(SynonymMap), typeof(string), typeof(string))] |
| | 11 | | public partial class SynonymMap |
| | 12 | | { |
| | 13 | | private const string DefaultFormat = "solr"; |
| | 14 | |
|
| | 15 | | [CodeGenMember("etag")] |
| | 16 | | private string _etag; |
| | 17 | |
|
| | 18 | | // TODO: Replace constructor and read-only properties when https://github.com/Azure/autorest.csharp/issues/554 i |
| | 19 | |
|
| | 20 | | /// <summary> |
| | 21 | | /// Initializes a new instance of the <see cref="SynonymMap"/> class. |
| | 22 | | /// </summary> |
| | 23 | | /// <param name="name">The name of the synonym map.</param> |
| | 24 | | /// <param name="synonyms"> |
| | 25 | | /// The formatted synonyms string to define. |
| | 26 | | /// Because only the "solr" synonym map format is currently supported, these are values delimited by "\n". |
| | 27 | | /// </param> |
| | 28 | | /// <exception cref="ArgumentException"><paramref name="name"/> or <paramref name="synonyms"/> is an empty strin |
| | 29 | | /// <exception cref="ArgumentNullException"><paramref name="name"/> or <paramref name="synonyms"/> is null.</exc |
| 11 | 30 | | public SynonymMap(string name, string synonyms) |
| | 31 | | { |
| 11 | 32 | | Argument.AssertNotNullOrEmpty(name, nameof(name)); |
| 9 | 33 | | Argument.AssertNotNullOrEmpty(synonyms, nameof(synonyms)); |
| | 34 | |
|
| 7 | 35 | | Name = name; |
| 7 | 36 | | Format = DefaultFormat; |
| 7 | 37 | | Synonyms = synonyms; |
| 7 | 38 | | } |
| | 39 | |
|
| | 40 | | /// <summary> |
| | 41 | | /// Initializes a new instance of the <see cref="SynonymMap"/> class. |
| | 42 | | /// </summary> |
| | 43 | | /// <param name="name">The name of the synonym map.</param> |
| | 44 | | /// <param name="reader"> |
| | 45 | | /// A <see cref="TextReader"/> from which formatted synonyms are read. |
| | 46 | | /// Because only the "solr" synonym map format is currently supported, these are values delimited by "\n". |
| | 47 | | /// </param> |
| | 48 | | /// <exception cref="ArgumentException"><paramref name="name"/> is an empty string.</exception> |
| | 49 | | /// <exception cref="ArgumentNullException"><paramref name="name"/> or <paramref name="reader"/> is null.</excep |
| 4 | 50 | | public SynonymMap(string name, TextReader reader) |
| | 51 | | { |
| 4 | 52 | | Argument.AssertNotNullOrEmpty(name, nameof(name)); |
| 2 | 53 | | Argument.AssertNotNull(reader, nameof(reader)); |
| | 54 | |
|
| 1 | 55 | | Name = name; |
| 1 | 56 | | Format = DefaultFormat; |
| 1 | 57 | | Synonyms = reader.ReadToEnd(); |
| 1 | 58 | | } |
| | 59 | |
|
| | 60 | | /// <summary> |
| | 61 | | /// The <see cref="Azure.ETag"/> of the <see cref="SynonymMap"/>. |
| | 62 | | /// </summary> |
| | 63 | | public ETag? ETag |
| | 64 | | { |
| 13 | 65 | | get => _etag is null ? (ETag?)null : new ETag(_etag); |
| 4 | 66 | | set => _etag = value?.ToString(); |
| | 67 | | } |
| | 68 | |
|
| | 69 | | /// <summary> The format of the synonym map. Only the "solr" format is currently supported. </summary> |
| 31 | 70 | | internal string Format { get; set; } |
| | 71 | | } |
| | 72 | | } |