-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
SearchFieldDataType.cs
63 lines (50 loc) · 3.22 KB
/
SearchFieldDataType.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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System;
using Azure.Core;
namespace Azure.Search.Documents.Indexes.Models
{
public readonly partial struct SearchFieldDataType
{
private const string CollectionPrefix = "Collection(";
#pragma warning disable CA1720 // Identifier contains type name
/// <summary>A <see cref="string"/> type.</summary>
[CodeGenMember("EdmString")]
public static SearchFieldDataType String { get; } = new SearchFieldDataType(StringValue);
/// <summary>An <see cref="int"/> type, or something that can convert to an <see cref="int"/>.</summary>
[CodeGenMember("EdmInt32")]
public static SearchFieldDataType Int32 { get; } = new SearchFieldDataType(Int32Value);
/// <summary>An <see cref="long"/> type, or something that can convert to an <see cref="long"/>.</summary>
[CodeGenMember("EdmInt64")]
public static SearchFieldDataType Int64 { get; } = new SearchFieldDataType(Int64Value);
/// <summary>A <see cref="double"/> type, or something that can convert to a <see cref="double"/>.</summary>
[CodeGenMember("EdmDouble")]
public static SearchFieldDataType Double { get; } = new SearchFieldDataType(DoubleValue);
#pragma warning restore CA1720 // Identifier contains type name
/// <summary>A <see cref="bool"/> type.</summary>
[CodeGenMember("EdmBoolean")]
public static SearchFieldDataType Boolean { get; } = new SearchFieldDataType(BooleanValue);
/// <summary>A <see cref="System.DateTimeOffset"/> type, or <see cref="System.DateTime"/> converted to a <see cref="System.DateTimeOffset"/>.</summary>
[CodeGenMember("EdmDateTimeOffset")]
public static SearchFieldDataType DateTimeOffset { get; } = new SearchFieldDataType(DateTimeOffsetValue);
/// <summary>A geographic point type.</summary>
[CodeGenMember("EdmGeographyPoint")]
public static SearchFieldDataType GeographyPoint { get; } = new SearchFieldDataType(GeographyPointValue);
/// <summary>A complex type with child fields.</summary>
[CodeGenMember("EdmComplexType")]
public static SearchFieldDataType Complex { get; } = new SearchFieldDataType(ComplexValue);
/// <summary>A single type.</summary>
[CodeGenMember("EdmSingle")]
public static SearchFieldDataType Single { get; } = new SearchFieldDataType(SingleValue);
/// <summary>
/// Gets a <see cref="SearchFieldDataType"/> representing a collection of <paramref name="type"/>.
/// </summary>
/// <param name="type">The type of collection.</param>
/// <returns>A <see cref="SearchFieldDataType"/> representing a collection of <paramref name="type"/>.</returns>
public static SearchFieldDataType Collection(SearchFieldDataType type) => type.IsCollection ? type : new SearchFieldDataType(string.Concat(CollectionPrefix, type._value, ")"));
/// <summary>
/// Gets a value indicating whether the <see cref="SearchFieldDataType"/> represents a collection.
/// </summary>
public bool IsCollection => _value.StartsWith(CollectionPrefix, StringComparison.InvariantCultureIgnoreCase);
}
}