< Summary

Class:Microsoft.Azure.CognitiveServices.Search.WebSearch.WebSearchClient
Assembly:Microsoft.Azure.CognitiveServices.Search.BingWebSearch
File(s):C:\Git\azure-sdk-for-net\sdk\cognitiveservices\Search.BingWebSearch\src\Generated\WebSearch\WebSearchClient.cs
Covered lines:48
Uncovered lines:21
Coverable lines:69
Total lines:218
Line coverage:69.5% (48 of 69)
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_Web()-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.BingWebSearch\src\Generated\WebSearch\WebSearchClient.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.WebSearch
 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 Web Search API lets you send a search query to Bing and get back
 20    /// search results that include links to webpages, images, and more.
 21    /// </summary>
 22    public partial class WebSearchClient : ServiceClient<WebSearchClient>, IWebSearchClient
 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>
 632        public JsonSerializerSettings SerializationSettings { get; private set; }
 33
 34        /// <summary>
 35        /// Gets or sets json deserialization settings.
 36        /// </summary>
 837        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 IWeb.
 53        /// </summary>
 454        public virtual IWeb Web { get; private set; }
 55
 56        /// <summary>
 57        /// Initializes a new instance of the WebSearchClient 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 WebSearchClient.Dispose(). False: will not dispose pro
 064        protected WebSearchClient(HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient)
 65        {
 066            Initialize();
 067        }
 68
 69        /// <summary>
 70        /// Initializes a new instance of the WebSearchClient class.
 71        /// </summary>
 72        /// <param name='handlers'>
 73        /// Optional. The delegating handlers to add to the http client pipeline.
 74        /// </param>
 275        protected WebSearchClient(params DelegatingHandler[] handlers) : base(handlers)
 76        {
 277            Initialize();
 278        }
 79
 80        /// <summary>
 81        /// Initializes a new instance of the WebSearchClient 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 WebSearchClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler
 90        {
 091            Initialize();
 092        }
 93
 94        /// <summary>
 95        /// Initializes a new instance of the WebSearchClient 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 WebSearchClient(ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handler
 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 WebSearchClient 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 WebSearchClient.Dispose(). False: will not dispose pro
 130        /// <exception cref="System.ArgumentNullException">
 131        /// Thrown when a required parameter is null
 132        /// </exception>
 0133        public WebSearchClient(ServiceClientCredentials credentials, HttpClient httpClient, bool disposeHttpClient) : th
 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 WebSearchClient 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 WebSearchClient(ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHan
 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            Web = new Web(this);
 2184            BaseUri = "{Endpoint}/bing/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<WebWebGrouping>("_type"));
 2212            DeserializationSettings.Converters.Add(new  PolymorphicDeserializeJsonConverter<WebWebGrouping>("_type"));
 2213            SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter<ResponseBase>("_type"));
 2214            DeserializationSettings.Converters.Add(new  PolymorphicDeserializeJsonConverter<ResponseBase>("_type"));
 215            CustomInitialize();
 2216        }
 217    }
 218}