| | 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 | | using System; |
| | 6 | | using Microsoft.Azure.Search.Common; |
| | 7 | | using Microsoft.Azure.Search.Serialization; |
| | 8 | | using Newtonsoft.Json; |
| | 9 | |
|
| | 10 | | namespace Microsoft.Azure.Search.Models |
| | 11 | | { |
| | 12 | | /// <summary> |
| | 13 | | /// Defines the type of a datasource. |
| | 14 | | /// </summary> |
| | 15 | | [JsonConverter(typeof(ExtensibleEnumConverter<DataSourceType>))] |
| | 16 | | public struct DataSourceType : IEquatable<DataSourceType> |
| | 17 | | { |
| | 18 | | private readonly string _value; |
| | 19 | |
|
| | 20 | | /// <summary> |
| | 21 | | /// Indicates an Azure SQL datasource. |
| | 22 | | /// </summary> |
| 2 | 23 | | public static readonly DataSourceType AzureSql = new DataSourceType("azuresql"); |
| | 24 | |
|
| | 25 | | /// <summary> |
| | 26 | | /// Indicates a DocumentDB datasource. |
| | 27 | | /// </summary> |
| | 28 | | [Obsolete("This member is deprecated. Use CosmosDb instead")] |
| 2 | 29 | | public static readonly DataSourceType DocumentDb = new DataSourceType("documentdb"); |
| | 30 | |
|
| | 31 | | /// <summary> |
| | 32 | | /// Indicates a CosmosDB datasource. |
| | 33 | | /// </summary> |
| 2 | 34 | | public static readonly DataSourceType CosmosDb = new DataSourceType("cosmosdb"); |
| | 35 | |
|
| | 36 | | /// <summary> |
| | 37 | | /// Indicates a Azure Blob datasource. |
| | 38 | | /// </summary> |
| 2 | 39 | | public static readonly DataSourceType AzureBlob = new DataSourceType("azureblob"); |
| | 40 | |
|
| | 41 | | /// <summary> |
| | 42 | | /// Indicates a Azure Table datasource. |
| | 43 | | /// </summary> |
| 2 | 44 | | public static readonly DataSourceType AzureTable = new DataSourceType("azuretable"); |
| | 45 | |
|
| | 46 | | private DataSourceType(string typeName) |
| | 47 | | { |
| 194 | 48 | | Throw.IfArgumentNull(typeName, nameof(typeName)); |
| 194 | 49 | | _value = typeName; |
| 194 | 50 | | } |
| | 51 | |
|
| | 52 | | /// <summary> |
| | 53 | | /// Defines implicit conversion from string to DataSourceType. |
| | 54 | | /// </summary> |
| | 55 | | /// <param name="value">string to convert.</param> |
| | 56 | | /// <returns>The string as a DataSourceType.</returns> |
| 2 | 57 | | public static implicit operator DataSourceType(string value) => new DataSourceType(value); |
| | 58 | |
|
| | 59 | | /// <summary> |
| | 60 | | /// Defines explicit conversion from DataSourceType to string. |
| | 61 | | /// </summary> |
| | 62 | | /// <param name="dataSourceType">DataSourceType to convert.</param> |
| | 63 | | /// <returns>The DataSourceType as a string.</returns> |
| 0 | 64 | | public static explicit operator string(DataSourceType dataSourceType) => dataSourceType.ToString(); |
| | 65 | |
|
| | 66 | | /// <summary> |
| | 67 | | /// Compares two DataSourceType values for equality. |
| | 68 | | /// </summary> |
| | 69 | | /// <param name="lhs">The first DataSourceType to compare.</param> |
| | 70 | | /// <param name="rhs">The second DataSourceType to compare.</param> |
| | 71 | | /// <returns>true if the DataSourceType objects are equal or are both null; false otherwise.</returns> |
| 0 | 72 | | public static bool operator ==(DataSourceType lhs, DataSourceType rhs) => Equals(lhs, rhs); |
| | 73 | |
|
| | 74 | | /// <summary> |
| | 75 | | /// Compares two DataSourceType values for inequality. |
| | 76 | | /// </summary> |
| | 77 | | /// <param name="lhs">The first DataSourceType to compare.</param> |
| | 78 | | /// <param name="rhs">The second DataSourceType to compare.</param> |
| | 79 | | /// <returns>true if the DataSourceType objects are not equal; false otherwise.</returns> |
| 0 | 80 | | public static bool operator !=(DataSourceType lhs, DataSourceType rhs) => !Equals(lhs, rhs); |
| | 81 | |
|
| | 82 | | /// <summary> |
| | 83 | | /// Compares the DataSourceType for equality with another DataSourceType. |
| | 84 | | /// </summary> |
| | 85 | | /// <param name="other">The DataSourceType with which to compare.</param> |
| | 86 | | /// <returns><c>true</c> if the DataSourceType objects are equal; otherwise, <c>false</c>.</returns> |
| 66 | 87 | | public bool Equals(DataSourceType other) => _value == other._value; |
| | 88 | |
|
| | 89 | | /// <summary> |
| | 90 | | /// Determines whether the specified object is equal to the current object. |
| | 91 | | /// </summary> |
| | 92 | | /// <param name="obj">The object to compare with the current object.</param> |
| | 93 | | /// <returns><c>true</c> if the specified object is equal to the current object; otherwise, <c>false</c>.</retur |
| 0 | 94 | | public override bool Equals(object obj) => obj is DataSourceType ? Equals((DataSourceType)obj) : false; |
| | 95 | |
|
| | 96 | | /// <summary> |
| | 97 | | /// Serves as the default hash function. |
| | 98 | | /// </summary> |
| | 99 | | /// <returns>A hash code for the current object.</returns> |
| 0 | 100 | | public override int GetHashCode() => _value.GetHashCode(); |
| | 101 | |
|
| | 102 | | /// <summary> |
| | 103 | | /// Returns a string representation of the DataSourceType. |
| | 104 | | /// </summary> |
| | 105 | | /// <returns>The DataSourceType as a string.</returns> |
| 152 | 106 | | public override string ToString() => _value; |
| | 107 | | } |
| | 108 | | } |