< Summary

Class:Microsoft.Azure.Search.IndexesGetClientExtensions
Assembly:Microsoft.Azure.Search
File(s):C:\Git\azure-sdk-for-net\sdk\search\Microsoft.Azure.Search\src\IndexesGetClientExtensions.cs
Covered lines:9
Uncovered lines:0
Coverable lines:9
Total lines:43
Line coverage:100% (9 of 9)
Covered branches:0
Total branches:0

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
GetClient(...)-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\search\Microsoft.Azure.Search\src\IndexesGetClientExtensions.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
 5namespace Microsoft.Azure.Search
 6{
 7    using System.Linq;
 8    using System.Net.Http;
 9
 10    /// <summary>
 11    /// Defines an extension method for obtaining a pre-configured SearchIndexClient from the Indexes property
 12    /// of a SearchServiceClient.
 13    /// </summary>
 14    public static class IndexesGetClientExtensions
 15    {
 16        /// <summary>
 17        /// Creates a new index client for querying and managing documents in a given index.
 18        /// </summary>
 19        /// <param name="operations">The operation group for indexes of the Search service.</param>
 20        /// <param name="indexName">The name of the index.</param>
 21        /// <returns>A new <c cref="Microsoft.Azure.Search.SearchIndexClient">SearchIndexClient</c> instance.</returns>
 22        /// <remarks>
 23        /// The new client is configured with full read-write access to the index. If you are only planning to use the
 24        /// client for query operations, we recommend directly creating a
 25        /// <c cref="Microsoft.Azure.Search.SearchIndexClient">SearchIndexClient</c> instance instead.
 26        /// </remarks>
 27        public static ISearchIndexClient GetClient(this IIndexesOperations operations, string indexName)
 28        {
 29            // Argument checking is done by the SearchIndexClient constructor. Note that HttpClient can't be shared in
 30            // case it has already been used (SearchIndexClient will attempt to set the Timeout property on it).
 831            SearchServiceClient serviceClient = operations.Client;
 832            var rootHandler = serviceClient.HttpMessageHandlers.OfType<HttpClientHandler>().SingleOrDefault();
 833            var indexClient =
 834                new SearchIndexClient(serviceClient.SearchServiceName, indexName, serviceClient.SearchCredentials, rootH
 835                {
 836                    SearchDnsSuffix = serviceClient.SearchDnsSuffix
 837                };
 38
 839            indexClient.HttpClient.Timeout = serviceClient.HttpClient.Timeout;
 840            return indexClient;
 41        }
 42    }
 43}

Methods/Properties

GetClient(...)