/// <summary>
        /// Get Platform Resource from PlatformService directly.
        /// </summary>
        /// <typeparam name="TResource">The type of related platform resource.</typeparam>
        /// <param name="requestUri">The request uri for the related platform resource.</param>
        /// <param name="loggingContext">The logging context.</param>
        /// <returns>The related platform resource.</returns>
        protected async Task <TResource> GetLatestPlatformServiceResourceAsync <TResource>(
            Uri requestUri,
            LoggingContext loggingContext)
            where TResource : Resource
        {
            LoggingContext localLoggingContext = loggingContext == null ? new LoggingContext() : loggingContext.Clone() as LoggingContext;

            var customerHeaders = new Dictionary <string, string>();

            Logger.Instance.Information("calling  GetLatestPlatformServiceResourceAsync " + requestUri.ToString() + "\r\n" + localLoggingContext.ToString());

            localLoggingContext.PropertyBag[Constants.RemotePlatformServiceUri] = requestUri;
            if (!string.IsNullOrEmpty(loggingContext?.JobId))
            {
                customerHeaders.Add(Constants.UcapClientRequestId, loggingContext.JobId);
            }

            DateTime startTime = DateTime.UtcNow;

            var result = default(TResource);

            try
            {
                var httpResponse = await RestfulClient.GetAsync(requestUri, customerHeaders).ConfigureAwait(false);

                localLoggingContext.FillTracingInfoFromHeaders(httpResponse.Headers, false);
                if (httpResponse.IsSuccessStatusCode ||
                    (httpResponse.StatusCode == HttpStatusCode.NotFound &&
                     !string.IsNullOrWhiteSpace(loggingContext.PlatformResponseCorrelationId) &&
                     !string.IsNullOrWhiteSpace(loggingContext.PlatformResponseServerFqdn)))
                {
                    if (httpResponse.StatusCode != HttpStatusCode.NoContent && httpResponse.StatusCode != HttpStatusCode.NotFound && httpResponse.Content != null)
                    {
                        var platformResourceStream = await httpResponse.Content.ReadAsStreamAsync().ConfigureAwait(false);

                        result = MediaTypeFormattersHelper.ReadContentWithType(typeof(TResource), httpResponse.Content.Headers.ContentType, platformResourceStream) as TResource;
                    }
                }
                else
                {
                    var serverSideEx = await RemotePlatformServiceException.ConvertToRemotePlatformServiceExceptionAsync(httpResponse, loggingContext).ConfigureAwait(false);

                    if (serverSideEx != null)
                    {
                        throw serverSideEx;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Instance.Error(ex,
                                      "calling  GetLatestPlatformServiceResourceAsync " + requestUri.ToString() + " ERROR\r\n" + localLoggingContext.ToString());
                throw;
            }
            return(result);
        }
        /// <summary>
        /// Delete the related Platform Resource.
        /// </summary>
        /// <param name="requestUri">The request uri.</param>
        /// <param name="loggingContext">The logging context.</param>
        /// <returns>The task.</returns>
        protected async Task DeleteRelatedPlatformResourceAsync(Uri requestUri, LoggingContext loggingContext)
        {
            LoggingContext localLoggingContext = loggingContext == null ? null : loggingContext.Clone() as LoggingContext;
            var            customerHeaders     = new Dictionary <string, string>();

            if (localLoggingContext == null)
            {
                localLoggingContext = new LoggingContext();
            }

            Logger.Instance.Information("calling" + this.GetType().Name + "  DeleteRelatedPlatformResourceAsync " + requestUri.ToString() + "\r\n" + localLoggingContext.ToString());

            localLoggingContext.PropertyBag[Constants.RemotePlatformServiceUri] = requestUri;
            if (!string.IsNullOrEmpty(loggingContext?.JobId))
            {
                customerHeaders.Add(Constants.UcapClientRequestId, loggingContext.JobId);
            }

            try
            {
                var httpResponse = await this.RestfulClient.DeleteAsync(requestUri, customerHeaders).ConfigureAwait(false);

                localLoggingContext.FillTracingInfoFromHeaders(httpResponse.Headers, false);
                if (!httpResponse.IsSuccessStatusCode)
                {
                    if (httpResponse.StatusCode == HttpStatusCode.NotFound &&
                        !string.IsNullOrWhiteSpace(loggingContext.PlatformResponseCorrelationId) &&
                        !string.IsNullOrWhiteSpace(loggingContext.PlatformResponseServerFqdn))
                    {
                        return;
                    }

                    var serverSideEx = await RemotePlatformServiceException.ConvertToRemotePlatformServiceExceptionAsync(httpResponse, loggingContext).ConfigureAwait(false);

                    if (serverSideEx != null)
                    {
                        throw serverSideEx;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Instance.Error(ex,
                                      "calling  DeleteRelatedPlatformResourceAsync " + requestUri.ToString() + " ERROR\r\n" + localLoggingContext.ToString());
                throw;
            }
        }
        /// <summary>
        /// Create related Platform Resource.
        /// </summary>
        /// <param name="requestUri">The request uri.</param>
        /// <param name="content">The content which you posted.</param>
        /// <param name="loggingContext">The logging context.</param>
        /// <returns>The HttpResponse Message.</returns>
        protected async Task <HttpResponseMessage> PostRelatedPlatformResourceAsync(Uri requestUri, HttpContent content, LoggingContext loggingContext)
        {
            LoggingContext localLoggingContext = loggingContext == null ? null : loggingContext.Clone() as LoggingContext;

            var customerHeaders = new Dictionary <string, string>();

            if (localLoggingContext == null)
            {
                localLoggingContext = new LoggingContext();
            }

            Logger.Instance.Information("calling" + this.GetType().Name + "  PostRelatedPlatformResourceAsync " + requestUri.ToString() + "\r\n" + localLoggingContext.ToString());

            localLoggingContext.PropertyBag[Constants.RemotePlatformServiceUri] = requestUri;
            if (!string.IsNullOrEmpty(loggingContext?.JobId))
            {
                customerHeaders.Add(Constants.UcapClientRequestId, loggingContext.JobId);
            }

            var startTime = DateTime.UtcNow;
            var serverSideTrackingGuid = string.Empty;

            try
            {
                var httpResponseMesssage = await this.RestfulClient.PostAsync(requestUri, content, customerHeaders).ConfigureAwait(false);

                localLoggingContext.FillTracingInfoFromHeaders(httpResponseMesssage.Headers, false);
                if (!httpResponseMesssage.IsSuccessStatusCode)
                {
                    var serverSideEx = await RemotePlatformServiceException.ConvertToRemotePlatformServiceExceptionAsync(httpResponseMesssage, localLoggingContext).ConfigureAwait(false);

                    if (serverSideEx != null)
                    {
                        throw serverSideEx;
                    }
                }

                return(httpResponseMesssage);
            }
            catch (Exception ex)
            {
                Logger.Instance.Error(ex,
                                      "calling  PostRelatedPlatformResourceAsync " + requestUri.ToString() + " ERROR\r\n" + localLoggingContext.ToString());
                throw;
            }
        }
        /// <summary>
        /// Update the related Platform Resource.
        /// </summary>
        /// <typeparam name="TInput">The type of platform input resource.</typeparam>
        /// <param name="requestUri">The request uri.</param>
        /// <param name="input">The platform input resource.</param>
        /// <param name="mediaTypeFormatter">The media type formatter to serialize.</param>
        /// <param name="loggingContext">The logging context.</param>
        /// <returns>The task.</returns>
        protected async Task <HttpResponseMessage> PutRelatedPlatformResourceAsync <TInput>(Uri requestUri, TInput input, MediaTypeFormatter mediaTypeFormatter, LoggingContext loggingContext)
            where TInput : class
        {
            LoggingContext localLoggingContext = loggingContext == null ? null : loggingContext.Clone() as LoggingContext;

            var customerHeaders = new Dictionary <string, string>();

            if (localLoggingContext == null)
            {
                localLoggingContext = new LoggingContext();
            }

            Logger.Instance.Information("calling" + this.GetType().Name + "  PutRelatedPlatformResourceAsync " + requestUri.ToString() + "\r\n" + localLoggingContext.ToString());

            localLoggingContext.PropertyBag[Constants.RemotePlatformServiceUri] = requestUri;
            if (!string.IsNullOrEmpty(loggingContext?.JobId))
            {
                customerHeaders.Add(Constants.UcapClientRequestId, loggingContext.JobId.ToString());
            }

            try
            {
                var httpResponse = await this.RestfulClient.PutAsync(requestUri, input, mediaTypeFormatter, customerHeaders).ConfigureAwait(false);

                localLoggingContext.FillTracingInfoFromHeaders(httpResponse.Headers, false);
                if (!httpResponse.IsSuccessStatusCode)
                {
                    var serverSideEx = await RemotePlatformServiceException.ConvertToRemotePlatformServiceExceptionAsync(httpResponse, localLoggingContext).ConfigureAwait(false);

                    if (serverSideEx != null)
                    {
                        throw serverSideEx;
                    }
                }
                return(httpResponse);
            }
            catch (Exception ex)
            {
                //handle and rethrow exception
                Logger.Instance.Error(ex,
                                      "calling  PostRelatedPlatformResourceAsync " + requestUri.ToString() + " ERROR\r\n" + localLoggingContext.ToString());
                throw;
            }
        }