< Summary

Class:Microsoft.Azure.CognitiveServices.Personalizer.Evaluations
Assembly:Microsoft.Azure.CognitiveServices.Personalizer
File(s):C:\Git\azure-sdk-for-net\sdk\cognitiveservices\Personalizer\src\Generated\Evaluations.cs
Covered lines:154
Uncovered lines:133
Coverable lines:287
Total lines:670
Line coverage:53.6% (154 of 287)
Covered branches:60
Total branches:146
Branch coverage:41% (60 of 146)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-80%50%
get_Client()-100%100%
GetWithHttpMessagesAsync()-51.35%42.11%
DeleteWithHttpMessagesAsync()-55.74%41.18%
ListWithHttpMessagesAsync()-53.97%37.5%
CreateWithHttpMessagesAsync()-51.81%42.5%

File(s)

C:\Git\azure-sdk-for-net\sdk\cognitiveservices\Personalizer\src\Generated\Evaluations.cs

#LineLine coverage
 1// <auto-generated>
 2// Copyright (c) Microsoft Corporation. All rights reserved.
 3// Licensed under the MIT License. See License.txt in the project root for
 4// license information.
 5//
 6// Code generated by Microsoft (R) AutoRest Code Generator.
 7// Changes may cause incorrect behavior and will be lost if the code is
 8// regenerated.
 9// </auto-generated>
 10
 11namespace Microsoft.Azure.CognitiveServices.Personalizer
 12{
 13    using Microsoft.Rest;
 14    using Models;
 15    using Newtonsoft.Json;
 16    using System.Collections;
 17    using System.Collections.Generic;
 18    using System.IO;
 19    using System.Linq;
 20    using System.Net;
 21    using System.Net.Http;
 22    using System.Threading;
 23    using System.Threading.Tasks;
 24
 25    /// <summary>
 26    /// Evaluations operations.
 27    /// </summary>
 28    public partial class Evaluations : IServiceOperations<PersonalizerClient>, IEvaluations
 29    {
 30        /// <summary>
 31        /// Initializes a new instance of the Evaluations class.
 32        /// </summary>
 33        /// <param name='client'>
 34        /// Reference to the service client.
 35        /// </param>
 36        /// <exception cref="System.ArgumentNullException">
 37        /// Thrown when a required parameter is null
 38        /// </exception>
 3439        public Evaluations(PersonalizerClient client)
 40        {
 3441            if (client == null)
 42            {
 043                throw new System.ArgumentNullException("client");
 44            }
 3445            Client = client;
 3446        }
 47
 48        /// <summary>
 49        /// Gets a reference to the PersonalizerClient
 50        /// </summary>
 9251        public PersonalizerClient Client { get; private set; }
 52
 53        /// <summary>
 54        /// Get Evaluation.
 55        /// </summary>
 56        /// <remarks>
 57        /// Get the evaluation associated with the Id.
 58        /// </remarks>
 59        /// <param name='evaluationId'>
 60        /// Id of the evaluation.
 61        /// </param>
 62        /// <param name='customHeaders'>
 63        /// Headers that will be added to request.
 64        /// </param>
 65        /// <param name='cancellationToken'>
 66        /// The cancellation token.
 67        /// </param>
 68        /// <exception cref="ErrorResponseException">
 69        /// Thrown when the operation returned an invalid status code
 70        /// </exception>
 71        /// <exception cref="SerializationException">
 72        /// Thrown when unable to deserialize the response
 73        /// </exception>
 74        /// <exception cref="ValidationException">
 75        /// Thrown when a required parameter is null
 76        /// </exception>
 77        /// <exception cref="System.ArgumentNullException">
 78        /// Thrown when a required parameter is null
 79        /// </exception>
 80        /// <return>
 81        /// A response object containing the response body and response headers.
 82        /// </return>
 83        public async Task<HttpOperationResponse<Evaluation>> GetWithHttpMessagesAsync(string evaluationId, Dictionary<st
 84        {
 285            if (Client.Endpoint == null)
 86            {
 087                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 88            }
 289            if (evaluationId == null)
 90            {
 091                throw new ValidationException(ValidationRules.CannotBeNull, "evaluationId");
 92            }
 293            if (evaluationId != null)
 94            {
 295                if (evaluationId.Length > 256)
 96                {
 097                    throw new ValidationException(ValidationRules.MaxLength, "evaluationId", 256);
 98                }
 99            }
 100            // Tracing
 2101            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 2102            string _invocationId = null;
 2103            if (_shouldTrace)
 104            {
 0105                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0106                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0107                tracingParameters.Add("evaluationId", evaluationId);
 0108                tracingParameters.Add("cancellationToken", cancellationToken);
 0109                ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters);
 110            }
 111            // Construct URL
 2112            var _baseUrl = Client.BaseUri;
 2113            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "evaluations/{evaluationId}";
 2114            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 2115            _url = _url.Replace("{evaluationId}", System.Uri.EscapeDataString(evaluationId));
 116            // Create HTTP transport objects
 2117            var _httpRequest = new HttpRequestMessage();
 2118            HttpResponseMessage _httpResponse = null;
 2119            _httpRequest.Method = new HttpMethod("GET");
 2120            _httpRequest.RequestUri = new System.Uri(_url);
 121            // Set Headers
 122
 123
 2124            if (customHeaders != null)
 125            {
 0126                foreach(var _header in customHeaders)
 127                {
 0128                    if (_httpRequest.Headers.Contains(_header.Key))
 129                    {
 0130                        _httpRequest.Headers.Remove(_header.Key);
 131                    }
 0132                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 133                }
 134            }
 135
 136            // Serialize Request
 2137            string _requestContent = null;
 138            // Set Credentials
 2139            if (Client.Credentials != null)
 140            {
 2141                cancellationToken.ThrowIfCancellationRequested();
 2142                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 143            }
 144            // Send Request
 2145            if (_shouldTrace)
 146            {
 0147                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 148            }
 2149            cancellationToken.ThrowIfCancellationRequested();
 2150            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2151            if (_shouldTrace)
 152            {
 0153                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 154            }
 2155            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 2156            cancellationToken.ThrowIfCancellationRequested();
 2157            string _responseContent = null;
 2158            if ((int)_statusCode != 200)
 159            {
 0160                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 161                try
 162                {
 0163                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0164                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 0165                    if (_errorBody != null)
 166                    {
 0167                        ex.Body = _errorBody;
 168                    }
 0169                }
 0170                catch (JsonException)
 171                {
 172                    // Ignore the exception
 0173                }
 0174                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0175                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0176                if (_shouldTrace)
 177                {
 0178                    ServiceClientTracing.Error(_invocationId, ex);
 179                }
 0180                _httpRequest.Dispose();
 0181                if (_httpResponse != null)
 182                {
 0183                    _httpResponse.Dispose();
 184                }
 0185                throw ex;
 186            }
 187            // Create Result
 2188            var _result = new HttpOperationResponse<Evaluation>();
 2189            _result.Request = _httpRequest;
 2190            _result.Response = _httpResponse;
 191            // Deserialize Response
 2192            if ((int)_statusCode == 200)
 193            {
 2194                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 195                try
 196                {
 2197                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Evaluation>(_responseContent, Cl
 2198                }
 0199                catch (JsonException ex)
 200                {
 0201                    _httpRequest.Dispose();
 0202                    if (_httpResponse != null)
 203                    {
 0204                        _httpResponse.Dispose();
 205                    }
 0206                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 207                }
 208            }
 2209            if (_shouldTrace)
 210            {
 0211                ServiceClientTracing.Exit(_invocationId, _result);
 212            }
 2213            return _result;
 2214        }
 215
 216        /// <summary>
 217        /// Delete Evaluation.
 218        /// </summary>
 219        /// <remarks>
 220        /// Delete the evaluation associated with the Id.
 221        /// </remarks>
 222        /// <param name='evaluationId'>
 223        /// Id of the evaluation to delete.
 224        /// </param>
 225        /// <param name='customHeaders'>
 226        /// Headers that will be added to request.
 227        /// </param>
 228        /// <param name='cancellationToken'>
 229        /// The cancellation token.
 230        /// </param>
 231        /// <exception cref="HttpOperationException">
 232        /// Thrown when the operation returned an invalid status code
 233        /// </exception>
 234        /// <exception cref="ValidationException">
 235        /// Thrown when a required parameter is null
 236        /// </exception>
 237        /// <exception cref="System.ArgumentNullException">
 238        /// Thrown when a required parameter is null
 239        /// </exception>
 240        /// <return>
 241        /// A response object containing the response body and response headers.
 242        /// </return>
 243        public async Task<HttpOperationResponse> DeleteWithHttpMessagesAsync(string evaluationId, Dictionary<string, Lis
 244        {
 2245            if (Client.Endpoint == null)
 246            {
 0247                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 248            }
 2249            if (evaluationId == null)
 250            {
 0251                throw new ValidationException(ValidationRules.CannotBeNull, "evaluationId");
 252            }
 2253            if (evaluationId != null)
 254            {
 2255                if (evaluationId.Length > 256)
 256                {
 0257                    throw new ValidationException(ValidationRules.MaxLength, "evaluationId", 256);
 258                }
 259            }
 260            // Tracing
 2261            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 2262            string _invocationId = null;
 2263            if (_shouldTrace)
 264            {
 0265                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0266                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0267                tracingParameters.Add("evaluationId", evaluationId);
 0268                tracingParameters.Add("cancellationToken", cancellationToken);
 0269                ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters);
 270            }
 271            // Construct URL
 2272            var _baseUrl = Client.BaseUri;
 2273            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "evaluations/{evaluationId}";
 2274            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 2275            _url = _url.Replace("{evaluationId}", System.Uri.EscapeDataString(evaluationId));
 276            // Create HTTP transport objects
 2277            var _httpRequest = new HttpRequestMessage();
 2278            HttpResponseMessage _httpResponse = null;
 2279            _httpRequest.Method = new HttpMethod("DELETE");
 2280            _httpRequest.RequestUri = new System.Uri(_url);
 281            // Set Headers
 282
 283
 2284            if (customHeaders != null)
 285            {
 0286                foreach(var _header in customHeaders)
 287                {
 0288                    if (_httpRequest.Headers.Contains(_header.Key))
 289                    {
 0290                        _httpRequest.Headers.Remove(_header.Key);
 291                    }
 0292                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 293                }
 294            }
 295
 296            // Serialize Request
 2297            string _requestContent = null;
 298            // Set Credentials
 2299            if (Client.Credentials != null)
 300            {
 2301                cancellationToken.ThrowIfCancellationRequested();
 2302                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 303            }
 304            // Send Request
 2305            if (_shouldTrace)
 306            {
 0307                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 308            }
 2309            cancellationToken.ThrowIfCancellationRequested();
 2310            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2311            if (_shouldTrace)
 312            {
 0313                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 314            }
 2315            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 2316            cancellationToken.ThrowIfCancellationRequested();
 2317            string _responseContent = null;
 2318            if ((int)_statusCode != 204)
 319            {
 0320                var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _st
 0321                if (_httpResponse.Content != null) {
 0322                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 323                }
 324                else {
 0325                    _responseContent = string.Empty;
 326                }
 0327                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0328                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0329                if (_shouldTrace)
 330                {
 0331                    ServiceClientTracing.Error(_invocationId, ex);
 332                }
 0333                _httpRequest.Dispose();
 0334                if (_httpResponse != null)
 335                {
 0336                    _httpResponse.Dispose();
 337                }
 0338                throw ex;
 339            }
 340            // Create Result
 2341            var _result = new HttpOperationResponse();
 2342            _result.Request = _httpRequest;
 2343            _result.Response = _httpResponse;
 2344            if (_shouldTrace)
 345            {
 0346                ServiceClientTracing.Exit(_invocationId, _result);
 347            }
 2348            return _result;
 2349        }
 350
 351        /// <summary>
 352        /// List Evaluations.
 353        /// </summary>
 354        /// <remarks>
 355        /// List all the submitted evaluations.
 356        /// </remarks>
 357        /// <param name='customHeaders'>
 358        /// Headers that will be added to request.
 359        /// </param>
 360        /// <param name='cancellationToken'>
 361        /// The cancellation token.
 362        /// </param>
 363        /// <exception cref="HttpOperationException">
 364        /// Thrown when the operation returned an invalid status code
 365        /// </exception>
 366        /// <exception cref="SerializationException">
 367        /// Thrown when unable to deserialize the response
 368        /// </exception>
 369        /// <exception cref="ValidationException">
 370        /// Thrown when a required parameter is null
 371        /// </exception>
 372        /// <exception cref="System.ArgumentNullException">
 373        /// Thrown when a required parameter is null
 374        /// </exception>
 375        /// <return>
 376        /// A response object containing the response body and response headers.
 377        /// </return>
 378        public async Task<HttpOperationResponse<IList<Evaluation>>> ListWithHttpMessagesAsync(Dictionary<string, List<st
 379        {
 2380            if (Client.Endpoint == null)
 381            {
 0382                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 383            }
 384            // Tracing
 2385            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 2386            string _invocationId = null;
 2387            if (_shouldTrace)
 388            {
 0389                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0390                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0391                tracingParameters.Add("cancellationToken", cancellationToken);
 0392                ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters);
 393            }
 394            // Construct URL
 2395            var _baseUrl = Client.BaseUri;
 2396            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "evaluations";
 2397            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 398            // Create HTTP transport objects
 2399            var _httpRequest = new HttpRequestMessage();
 2400            HttpResponseMessage _httpResponse = null;
 2401            _httpRequest.Method = new HttpMethod("GET");
 2402            _httpRequest.RequestUri = new System.Uri(_url);
 403            // Set Headers
 404
 405
 2406            if (customHeaders != null)
 407            {
 0408                foreach(var _header in customHeaders)
 409                {
 0410                    if (_httpRequest.Headers.Contains(_header.Key))
 411                    {
 0412                        _httpRequest.Headers.Remove(_header.Key);
 413                    }
 0414                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 415                }
 416            }
 417
 418            // Serialize Request
 2419            string _requestContent = null;
 420            // Set Credentials
 2421            if (Client.Credentials != null)
 422            {
 2423                cancellationToken.ThrowIfCancellationRequested();
 2424                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 425            }
 426            // Send Request
 2427            if (_shouldTrace)
 428            {
 0429                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 430            }
 2431            cancellationToken.ThrowIfCancellationRequested();
 2432            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2433            if (_shouldTrace)
 434            {
 0435                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 436            }
 2437            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 2438            cancellationToken.ThrowIfCancellationRequested();
 2439            string _responseContent = null;
 2440            if ((int)_statusCode != 200)
 441            {
 0442                var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _st
 0443                if (_httpResponse.Content != null) {
 0444                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 445                }
 446                else {
 0447                    _responseContent = string.Empty;
 448                }
 0449                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0450                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0451                if (_shouldTrace)
 452                {
 0453                    ServiceClientTracing.Error(_invocationId, ex);
 454                }
 0455                _httpRequest.Dispose();
 0456                if (_httpResponse != null)
 457                {
 0458                    _httpResponse.Dispose();
 459                }
 0460                throw ex;
 461            }
 462            // Create Result
 2463            var _result = new HttpOperationResponse<IList<Evaluation>>();
 2464            _result.Request = _httpRequest;
 2465            _result.Response = _httpResponse;
 466            // Deserialize Response
 2467            if ((int)_statusCode == 200)
 468            {
 2469                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 470                try
 471                {
 2472                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<Evaluation>>(_responseCont
 2473                }
 0474                catch (JsonException ex)
 475                {
 0476                    _httpRequest.Dispose();
 0477                    if (_httpResponse != null)
 478                    {
 0479                        _httpResponse.Dispose();
 480                    }
 0481                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 482                }
 483            }
 2484            if (_shouldTrace)
 485            {
 0486                ServiceClientTracing.Exit(_invocationId, _result);
 487            }
 2488            return _result;
 2489        }
 490
 491        /// <summary>
 492        /// Create Evaluation.
 493        /// </summary>
 494        /// <remarks>
 495        /// Submit a new evaluation job.
 496        /// </remarks>
 497        /// <param name='evaluation'>
 498        /// The evaluation job definition.
 499        /// </param>
 500        /// <param name='customHeaders'>
 501        /// Headers that will be added to request.
 502        /// </param>
 503        /// <param name='cancellationToken'>
 504        /// The cancellation token.
 505        /// </param>
 506        /// <exception cref="ErrorResponseException">
 507        /// Thrown when the operation returned an invalid status code
 508        /// </exception>
 509        /// <exception cref="SerializationException">
 510        /// Thrown when unable to deserialize the response
 511        /// </exception>
 512        /// <exception cref="ValidationException">
 513        /// Thrown when a required parameter is null
 514        /// </exception>
 515        /// <exception cref="System.ArgumentNullException">
 516        /// Thrown when a required parameter is null
 517        /// </exception>
 518        /// <return>
 519        /// A response object containing the response body and response headers.
 520        /// </return>
 521        public async Task<HttpOperationResponse<Evaluation,EvaluationsCreateHeaders>> CreateWithHttpMessagesAsync(Evalua
 522        {
 2523            if (Client.Endpoint == null)
 524            {
 0525                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 526            }
 2527            if (evaluation == null)
 528            {
 0529                throw new ValidationException(ValidationRules.CannotBeNull, "evaluation");
 530            }
 2531            if (evaluation != null)
 532            {
 2533                evaluation.Validate();
 534            }
 535            // Tracing
 2536            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 2537            string _invocationId = null;
 2538            if (_shouldTrace)
 539            {
 0540                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0541                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0542                tracingParameters.Add("evaluation", evaluation);
 0543                tracingParameters.Add("cancellationToken", cancellationToken);
 0544                ServiceClientTracing.Enter(_invocationId, this, "Create", tracingParameters);
 545            }
 546            // Construct URL
 2547            var _baseUrl = Client.BaseUri;
 2548            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "evaluations";
 2549            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 550            // Create HTTP transport objects
 2551            var _httpRequest = new HttpRequestMessage();
 2552            HttpResponseMessage _httpResponse = null;
 2553            _httpRequest.Method = new HttpMethod("POST");
 2554            _httpRequest.RequestUri = new System.Uri(_url);
 555            // Set Headers
 556
 557
 2558            if (customHeaders != null)
 559            {
 0560                foreach(var _header in customHeaders)
 561                {
 0562                    if (_httpRequest.Headers.Contains(_header.Key))
 563                    {
 0564                        _httpRequest.Headers.Remove(_header.Key);
 565                    }
 0566                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 567                }
 568            }
 569
 570            // Serialize Request
 2571            string _requestContent = null;
 2572            if(evaluation != null)
 573            {
 2574                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(evaluation, Client.SerializationSet
 2575                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 2576                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 577            }
 578            // Set Credentials
 2579            if (Client.Credentials != null)
 580            {
 2581                cancellationToken.ThrowIfCancellationRequested();
 2582                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 583            }
 584            // Send Request
 2585            if (_shouldTrace)
 586            {
 0587                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 588            }
 2589            cancellationToken.ThrowIfCancellationRequested();
 2590            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2591            if (_shouldTrace)
 592            {
 0593                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 594            }
 2595            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 2596            cancellationToken.ThrowIfCancellationRequested();
 2597            string _responseContent = null;
 2598            if ((int)_statusCode != 201)
 599            {
 0600                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 601                try
 602                {
 0603                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0604                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 0605                    if (_errorBody != null)
 606                    {
 0607                        ex.Body = _errorBody;
 608                    }
 0609                }
 0610                catch (JsonException)
 611                {
 612                    // Ignore the exception
 0613                }
 0614                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0615                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0616                if (_shouldTrace)
 617                {
 0618                    ServiceClientTracing.Error(_invocationId, ex);
 619                }
 0620                _httpRequest.Dispose();
 0621                if (_httpResponse != null)
 622                {
 0623                    _httpResponse.Dispose();
 624                }
 0625                throw ex;
 626            }
 627            // Create Result
 2628            var _result = new HttpOperationResponse<Evaluation,EvaluationsCreateHeaders>();
 2629            _result.Request = _httpRequest;
 2630            _result.Response = _httpResponse;
 631            // Deserialize Response
 2632            if ((int)_statusCode == 201)
 633            {
 2634                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 635                try
 636                {
 2637                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Evaluation>(_responseContent, Cl
 2638                }
 0639                catch (JsonException ex)
 640                {
 0641                    _httpRequest.Dispose();
 0642                    if (_httpResponse != null)
 643                    {
 0644                        _httpResponse.Dispose();
 645                    }
 0646                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 647                }
 648            }
 649            try
 650            {
 2651                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<EvaluationsCreateHeaders>(JsonSerializer.Cre
 2652            }
 0653            catch (JsonException ex)
 654            {
 0655                _httpRequest.Dispose();
 0656                if (_httpResponse != null)
 657                {
 0658                    _httpResponse.Dispose();
 659                }
 0660                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 661            }
 2662            if (_shouldTrace)
 663            {
 0664                ServiceClientTracing.Exit(_invocationId, _result);
 665            }
 2666            return _result;
 2667        }
 668
 669    }
 670}