| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using Azure.Core; |
| | 6 | |
|
| | 7 | | namespace Azure.Search.Documents.Indexes.Models |
| | 8 | | { |
| | 9 | | public readonly partial struct SearchFieldDataType |
| | 10 | | { |
| | 11 | | private const string CollectionPrefix = "Collection("; |
| | 12 | |
|
| | 13 | | #pragma warning disable CA1720 // Identifier contains type name |
| | 14 | | /// <summary>A <see cref="string"/> type.</summary> |
| | 15 | | [CodeGenMember("EdmString")] |
| 1132 | 16 | | public static SearchFieldDataType String { get; } = new SearchFieldDataType(StringValue); |
| | 17 | |
|
| | 18 | | /// <summary>An <see cref="int"/> type, or something that can convert to an <see cref="int"/>.</summary> |
| | 19 | | [CodeGenMember("EdmInt32")] |
| 22 | 20 | | public static SearchFieldDataType Int32 { get; } = new SearchFieldDataType(Int32Value); |
| | 21 | |
|
| | 22 | | /// <summary>An <see cref="long"/> type, or something that can convert to an <see cref="long"/>.</summary> |
| | 23 | | [CodeGenMember("EdmInt64")] |
| 9 | 24 | | public static SearchFieldDataType Int64 { get; } = new SearchFieldDataType(Int64Value); |
| | 25 | |
|
| | 26 | | /// <summary>A <see cref="double"/> type, or something that can convert to a <see cref="double"/>.</summary> |
| | 27 | | [CodeGenMember("EdmDouble")] |
| 13 | 28 | | public static SearchFieldDataType Double { get; } = new SearchFieldDataType(DoubleValue); |
| | 29 | | #pragma warning restore CA1720 // Identifier contains type name |
| | 30 | |
|
| | 31 | | /// <summary>A <see cref="bool"/> type.</summary> |
| | 32 | | [CodeGenMember("EdmBoolean")] |
| 21 | 33 | | public static SearchFieldDataType Boolean { get; } = new SearchFieldDataType(BooleanValue); |
| | 34 | |
|
| | 35 | | /// <summary>A <see cref="System.DateTimeOffset"/> type, or <see cref="System.DateTime"/> converted to a <see cr |
| | 36 | | [CodeGenMember("EdmDateTimeOffset")] |
| 20 | 37 | | public static SearchFieldDataType DateTimeOffset { get; } = new SearchFieldDataType(DateTimeOffsetValue); |
| | 38 | |
|
| | 39 | | /// <summary>A geographic point type.</summary> |
| | 40 | | [CodeGenMember("EdmGeographyPoint")] |
| 6 | 41 | | public static SearchFieldDataType GeographyPoint { get; } = new SearchFieldDataType(GeographyPointValue); |
| | 42 | |
|
| | 43 | | /// <summary>A complex type with child fields.</summary> |
| | 44 | | [CodeGenMember("EdmComplexType")] |
| 3161 | 45 | | public static SearchFieldDataType Complex { get; } = new SearchFieldDataType(ComplexValue); |
| | 46 | |
|
| | 47 | | /// <summary> |
| | 48 | | /// Gets a <see cref="SearchFieldDataType"/> representing a collection of <paramref name="type"/>. |
| | 49 | | /// </summary> |
| | 50 | | /// <param name="type">The type of collection.</param> |
| | 51 | | /// <returns>A <see cref="SearchFieldDataType"/> representing a collection of <paramref name="type"/>.</returns> |
| 5952 | 52 | | public static SearchFieldDataType Collection(SearchFieldDataType type) => type.IsCollection ? type : new SearchF |
| | 53 | |
|
| | 54 | | /// <summary> |
| | 55 | | /// Gets a value indicating whether the <see cref="SearchFieldDataType"/> represents a collection. |
| | 56 | | /// </summary> |
| 5954 | 57 | | public bool IsCollection => _value.StartsWith(CollectionPrefix, StringComparison.InvariantCultureIgnoreCase); |
| | 58 | | } |
| | 59 | | } |