| | | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | | 2 | | // Licensed under the MIT License. See License.txt in the project root for |
| | | 3 | | // license information. |
| | | 4 | | |
| | | 5 | | namespace Microsoft.Azure.Search.Models |
| | | 6 | | { |
| | | 7 | | using System; |
| | | 8 | | using Microsoft.Azure.Search.Common; |
| | | 9 | | using Newtonsoft.Json; |
| | | 10 | | using Serialization; |
| | | 11 | | |
| | | 12 | | /// <summary> |
| | | 13 | | /// Defines the names of all character filters supported by Azure Cognitive Search. |
| | | 14 | | /// For more information, see <see href="https://docs.microsoft.com/azure/search/index-add-custom-analyzers">Add cus |
| | | 15 | | /// </summary> |
| | | 16 | | [JsonConverter(typeof(ExtensibleEnumConverter<CharFilterName>))] |
| | | 17 | | public struct CharFilterName : IEquatable<CharFilterName> |
| | | 18 | | { |
| | | 19 | | private readonly string _value; |
| | | 20 | | |
| | | 21 | | // MAINTENANCE NOTE: Keep these ordered the same as the table on this page: |
| | | 22 | | // https://docs.microsoft.com/rest/api/searchservice/Custom-analyzers-in-Azure-Search |
| | | 23 | | |
| | | 24 | | /// <summary> |
| | | 25 | | /// A character filter that attempts to strip out HTML constructs. |
| | | 26 | | /// <see href="https://lucene.apache.org/core/4_10_3/analyzers-common/org/apache/lucene/analysis/charfilter/HTML |
| | | 27 | | /// </summary> |
| | 2 | 28 | | public static readonly CharFilterName HtmlStrip = new CharFilterName("html_strip"); |
| | | 29 | | |
| | | 30 | | private CharFilterName(string name) |
| | | 31 | | { |
| | 12 | 32 | | Throw.IfArgumentNull(name, nameof(name)); |
| | 12 | 33 | | _value = name; |
| | 12 | 34 | | } |
| | | 35 | | |
| | | 36 | | /// <summary> |
| | | 37 | | /// Defines implicit conversion from string to CharFilterName. |
| | | 38 | | /// </summary> |
| | | 39 | | /// <param name="name">string to convert.</param> |
| | | 40 | | /// <returns>The string as a CharFilterName.</returns> |
| | 4 | 41 | | public static implicit operator CharFilterName(string name) => new CharFilterName(name); |
| | | 42 | | |
| | | 43 | | /// <summary> |
| | | 44 | | /// Defines explicit conversion from CharFilterName to string. |
| | | 45 | | /// </summary> |
| | | 46 | | /// <param name="name">CharFilterName to convert.</param> |
| | | 47 | | /// <returns>The CharFilterName as a string.</returns> |
| | 0 | 48 | | public static explicit operator string(CharFilterName name) => name.ToString(); |
| | | 49 | | |
| | | 50 | | /// <summary> |
| | | 51 | | /// Compares two CharFilterName values for equality. |
| | | 52 | | /// </summary> |
| | | 53 | | /// <param name="lhs">The first CharFilterName to compare.</param> |
| | | 54 | | /// <param name="rhs">The second CharFilterName to compare.</param> |
| | | 55 | | /// <returns>true if the CharFilterName objects are equal or are both null; false otherwise.</returns> |
| | 0 | 56 | | public static bool operator ==(CharFilterName lhs, CharFilterName rhs) => Equals(lhs, rhs); |
| | | 57 | | |
| | | 58 | | /// <summary> |
| | | 59 | | /// Compares two CharFilterName values for inequality. |
| | | 60 | | /// </summary> |
| | | 61 | | /// <param name="lhs">The first CharFilterName to compare.</param> |
| | | 62 | | /// <param name="rhs">The second CharFilterName to compare.</param> |
| | | 63 | | /// <returns>true if the CharFilterName objects are not equal; false otherwise.</returns> |
| | 0 | 64 | | public static bool operator !=(CharFilterName lhs, CharFilterName rhs) => !Equals(lhs, rhs); |
| | | 65 | | |
| | | 66 | | /// <summary> |
| | | 67 | | /// Compares the CharFilterName for equality with another CharFilterName. |
| | | 68 | | /// </summary> |
| | | 69 | | /// <param name="other">The CharFilterName with which to compare.</param> |
| | | 70 | | /// <returns><c>true</c> if the CharFilterName objects are equal; otherwise, <c>false</c>.</returns> |
| | 4 | 71 | | public bool Equals(CharFilterName other) => _value == other._value; |
| | | 72 | | |
| | | 73 | | /// <summary> |
| | | 74 | | /// Determines whether the specified object is equal to the current object. |
| | | 75 | | /// </summary> |
| | | 76 | | /// <param name="obj">The object to compare with the current object.</param> |
| | | 77 | | /// <returns><c>true</c> if the specified object is equal to the current object; otherwise, <c>false</c>.</retur |
| | 0 | 78 | | public override bool Equals(object obj) => obj is CharFilterName ? Equals((CharFilterName)obj) : false; |
| | | 79 | | |
| | | 80 | | /// <summary> |
| | | 81 | | /// Serves as the default hash function. |
| | | 82 | | /// </summary> |
| | | 83 | | /// <returns>A hash code for the current object.</returns> |
| | 0 | 84 | | public override int GetHashCode() => _value.GetHashCode(); |
| | | 85 | | |
| | | 86 | | /// <summary> |
| | | 87 | | /// Returns a string representation of the CharFilterName. |
| | | 88 | | /// </summary> |
| | | 89 | | /// <returns>The CharFilterName as a string.</returns> |
| | 10 | 90 | | public override string ToString() => _value; |
| | | 91 | | } |
| | | 92 | | } |