< Summary

Class:Microsoft.Azure.Search.Models.DataSourceType
Assembly:Microsoft.Azure.Search.Service
File(s):C:\Git\azure-sdk-for-net\sdk\search\Microsoft.Azure.Search.Service\src\Customizations\DataSources\Models\DataSourceType.cs
Covered lines:11
Uncovered lines:5
Coverable lines:16
Total lines:108
Line coverage:68.7% (11 of 16)
Covered branches:0
Total branches:2
Branch coverage:0% (0 of 2)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.cctor()-100%100%
.ctor(...)-100%100%
op_Implicit(...)-100%100%
op_Explicit(...)-0%100%
op_Equality(...)-0%100%
op_Inequality(...)-0%100%
Equals(...)-100%100%
Equals(...)-0%0%
GetHashCode()-0%100%
ToString()-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\search\Microsoft.Azure.Search.Service\src\Customizations\DataSources\Models\DataSourceType.cs

#LineLine coverage
 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
 5using System;
 6using Microsoft.Azure.Search.Common;
 7using Microsoft.Azure.Search.Serialization;
 8using Newtonsoft.Json;
 9
 10namespace 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>
 223        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")]
 229        public static readonly DataSourceType DocumentDb = new DataSourceType("documentdb");
 30
 31        /// <summary>
 32        /// Indicates a CosmosDB datasource.
 33        /// </summary>
 234        public static readonly DataSourceType CosmosDb = new DataSourceType("cosmosdb");
 35
 36        /// <summary>
 37        /// Indicates a Azure Blob datasource.
 38        /// </summary>
 239        public static readonly DataSourceType AzureBlob = new DataSourceType("azureblob");
 40
 41        /// <summary>
 42        /// Indicates a Azure Table datasource.
 43        /// </summary>
 244        public static readonly DataSourceType AzureTable = new DataSourceType("azuretable");
 45
 46        private DataSourceType(string typeName)
 47        {
 19448            Throw.IfArgumentNull(typeName, nameof(typeName));
 19449            _value = typeName;
 19450        }
 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>
 257        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>
 064        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>
 072        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>
 080        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>
 6687        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
 094        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>
 0100        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>
 152106        public override string ToString() => _value;
 107    }
 108}