< Summary

Class:Microsoft.Azure.CognitiveServices.Search.CustomSearch.CustomSearchClient
Assembly:Microsoft.Azure.CognitiveServices.Search.BingCustomSearch
File(s):C:\Git\azure-sdk-for-net\sdk\cognitiveservices\Search.BingCustomSearch\src\Generated\CustomSearch\CustomSearchClient.cs
Covered lines:46
Uncovered lines:21
Coverable lines:67
Total lines:216
Line coverage:68.6% (46 of 67)
Covered branches:3
Total branches:12
Branch coverage:25% (3 of 12)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
get_BaseUri()-100%100%
get_SerializationSettings()-100%100%
get_DeserializationSettings()-100%100%
get_Endpoint()-100%100%
get_Credentials()-100%100%
get_CustomInstance()-100%100%
.ctor(...)-0%100%
.ctor(...)-100%100%
.ctor(...)-0%100%
.ctor(...)-85.71%75%
.ctor(...)-0%0%
.ctor(...)-0%0%
Initialize()-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\cognitiveservices\Search.BingCustomSearch\src\Generated\CustomSearch\CustomSearchClient.cs

#LineLine coverage
 1// <auto-generated>
 2// Code generated by Microsoft (R) AutoRest Code Generator.
 3// Changes may cause incorrect behavior and will be lost if the code is
 4// regenerated.
 5// </auto-generated>
 6
 7namespace Microsoft.Azure.CognitiveServices.Search.CustomSearch
 8{
 9    using Microsoft.Rest;
 10    using Microsoft.Rest.Serialization;
 11    using Models;
 12    using Newtonsoft.Json;
 13    using System.Collections;
 14    using System.Collections.Generic;
 15    using System.Net;
 16    using System.Net.Http;
 17
 18    /// <summary>
 19    /// The Bing Custom Search API lets you send a search query to Bing and get
 20    /// back search results customized to meet your custom search definition.
 21    /// </summary>
 22    public partial class CustomSearchClient : ServiceClient<CustomSearchClient>, ICustomSearchClient
 23    {
 24        /// <summary>
 25        /// The base URI of the service.
 26        /// </summary>
 427        internal string BaseUri {get; set;}
 28
 29        /// <summary>
 30        /// Gets or sets json serialization settings.
 31        /// </summary>
 432        public JsonSerializerSettings SerializationSettings { get; private set; }
 33
 34        /// <summary>
 35        /// Gets or sets json deserialization settings.
 36        /// </summary>
 637        public JsonSerializerSettings DeserializationSettings { get; private set; }
 38
 39        /// <summary>
 40        /// Supported Cognitive Services endpoints (protocol and hostname, for example:
 41        /// "https://westus.api.cognitive.microsoft.com",
 42        /// "https://api.cognitive.microsoft.com").
 43        /// </summary>
 644        public string Endpoint { get; set; }
 45
 46        /// <summary>
 47        /// Subscription credentials which uniquely identify client subscription.
 48        /// </summary>
 1049        public ServiceClientCredentials Credentials { get; private set; }
 50
 51        /// <summary>
 52        /// Gets the ICustomInstance.
 53        /// </summary>
 454        public virtual ICustomInstance CustomInstance { get; private set; }
 55
 56        /// <summary>
 57        /// Initializes a new instance of the CustomSearchClient class.
 58        /// </summary>
 59        /// <param name='httpClient'>
 60        /// HttpClient to be used
 61        /// </param>
 62        /// <param name='disposeHttpClient'>
 63        /// True: will dispose the provided httpClient on calling CustomSearchClient.Dispose(). False: will not dispose 
 064        protected CustomSearchClient(HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient
 65        {
 066            Initialize();
 067        }
 68
 69        /// <summary>
 70        /// Initializes a new instance of the CustomSearchClient class.
 71        /// </summary>
 72        /// <param name='handlers'>
 73        /// Optional. The delegating handlers to add to the http client pipeline.
 74        /// </param>
 275        protected CustomSearchClient(params DelegatingHandler[] handlers) : base(handlers)
 76        {
 277            Initialize();
 278        }
 79
 80        /// <summary>
 81        /// Initializes a new instance of the CustomSearchClient class.
 82        /// </summary>
 83        /// <param name='rootHandler'>
 84        /// Optional. The http client handler used to handle http transport.
 85        /// </param>
 86        /// <param name='handlers'>
 87        /// Optional. The delegating handlers to add to the http client pipeline.
 88        /// </param>
 089        protected CustomSearchClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHand
 90        {
 091            Initialize();
 092        }
 93
 94        /// <summary>
 95        /// Initializes a new instance of the CustomSearchClient class.
 96        /// </summary>
 97        /// <param name='credentials'>
 98        /// Required. Subscription credentials which uniquely identify client subscription.
 99        /// </param>
 100        /// <param name='handlers'>
 101        /// Optional. The delegating handlers to add to the http client pipeline.
 102        /// </param>
 103        /// <exception cref="System.ArgumentNullException">
 104        /// Thrown when a required parameter is null
 105        /// </exception>
 2106        public CustomSearchClient(ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(hand
 107        {
 2108            if (credentials == null)
 109            {
 0110                throw new System.ArgumentNullException("credentials");
 111            }
 2112            Credentials = credentials;
 2113            if (Credentials != null)
 114            {
 2115                Credentials.InitializeServiceClient(this);
 116            }
 2117        }
 118
 119        /// <summary>
 120        /// Initializes a new instance of the CustomSearchClient class.
 121        /// </summary>
 122        /// <param name='credentials'>
 123        /// Required. Subscription credentials which uniquely identify client subscription.
 124        /// </param>
 125        /// <param name='httpClient'>
 126        /// HttpClient to be used
 127        /// </param>
 128        /// <param name='disposeHttpClient'>
 129        /// True: will dispose the provided httpClient on calling CustomSearchClient.Dispose(). False: will not dispose 
 130        /// <exception cref="System.ArgumentNullException">
 131        /// Thrown when a required parameter is null
 132        /// </exception>
 0133        public CustomSearchClient(ServiceClientCredentials credentials, HttpClient httpClient, bool disposeHttpClient) :
 134        {
 0135            if (credentials == null)
 136            {
 0137                throw new System.ArgumentNullException("credentials");
 138            }
 0139            Credentials = credentials;
 0140            if (Credentials != null)
 141            {
 0142                Credentials.InitializeServiceClient(this);
 143            }
 0144        }
 145
 146        /// <summary>
 147        /// Initializes a new instance of the CustomSearchClient class.
 148        /// </summary>
 149        /// <param name='credentials'>
 150        /// Required. Subscription credentials which uniquely identify client subscription.
 151        /// </param>
 152        /// <param name='rootHandler'>
 153        /// Optional. The http client handler used to handle http transport.
 154        /// </param>
 155        /// <param name='handlers'>
 156        /// Optional. The delegating handlers to add to the http client pipeline.
 157        /// </param>
 158        /// <exception cref="System.ArgumentNullException">
 159        /// Thrown when a required parameter is null
 160        /// </exception>
 0161        public CustomSearchClient(ServiceClientCredentials credentials, HttpClientHandler rootHandler, params Delegating
 162        {
 0163            if (credentials == null)
 164            {
 0165                throw new System.ArgumentNullException("credentials");
 166            }
 0167            Credentials = credentials;
 0168            if (Credentials != null)
 169            {
 0170                Credentials.InitializeServiceClient(this);
 171            }
 0172        }
 173
 174        /// <summary>
 175        /// An optional partial-method to perform custom initialization.
 176        ///</summary>
 177        partial void CustomInitialize();
 178        /// <summary>
 179        /// Initializes client properties.
 180        /// </summary>
 181        private void Initialize()
 182        {
 2183            CustomInstance = new CustomInstance(this);
 2184            BaseUri = "{Endpoint}/bingcustomsearch/v7.0";
 2185            Endpoint = "https://api.cognitive.microsoft.com";
 2186            SerializationSettings = new JsonSerializerSettings
 2187            {
 2188                Formatting = Newtonsoft.Json.Formatting.Indented,
 2189                DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
 2190                DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc,
 2191                NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore,
 2192                ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
 2193                ContractResolver = new ReadOnlyJsonContractResolver(),
 2194                Converters = new  List<JsonConverter>
 2195                    {
 2196                        new Iso8601TimeSpanConverter()
 2197                    }
 2198            };
 2199            DeserializationSettings = new JsonSerializerSettings
 2200            {
 2201                DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
 2202                DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc,
 2203                NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore,
 2204                ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
 2205                ContractResolver = new ReadOnlyJsonContractResolver(),
 2206                Converters = new List<JsonConverter>
 2207                    {
 2208                        new Iso8601TimeSpanConverter()
 2209                    }
 2210            };
 2211            SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter<ResponseBase>("_type"));
 2212            DeserializationSettings.Converters.Add(new  PolymorphicDeserializeJsonConverter<ResponseBase>("_type"));
 213            CustomInitialize();
 2214        }
 215    }
 216}