コード例 #1
0
 /// <summary>
 /// Creates a clientRequestIdAdapter
 /// </summary>
 /// <returns>The new DataServiceContext instance.</returns>
 public override IWebRequestAdapter CreateClientRequestIdAdapter()
 {
     if (_clientRequestIdAdapter == null)
     {
         _clientRequestIdAdapter = new ClientRequestIdAdapter();
     }
     return(_clientRequestIdAdapter);
 }
        private Uri GetAccountApiEndpoint(OAuthDataServiceAdapter dataServiceAdapter, ServiceVersionAdapter versionAdapter, Uri apiServer, UserAgentAdapter userAgentAdapter, IWebRequestAdapter clientRequestIdAdapter)
        {
            MediaRetryPolicy retryPolicy = new MediaRetryPolicy(
                GetWebRequestTransientErrorDetectionStrategy(),
                RetryStrategyFactory.DefaultStrategy());

            Uri apiEndpoint = null;
            retryPolicy.ExecuteAction(
                    () =>
                    {
                        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(apiServer);
                        request.AllowAutoRedirect = false;
                        dataServiceAdapter.AddAccessTokenToRequest(request);
                        versionAdapter.AddVersionToRequest(request);
                        userAgentAdapter.AddUserAgentToRequest(request);
                        clientRequestIdAdapter.AddClientRequestId(request);

                        using (WebResponse response = request.GetResponse())
                        {
                            apiEndpoint = GetAccountApiEndpointFromResponse(response);
                        }
                    }
                );

            return apiEndpoint;
        }
 /// <summary>
 /// Creates a clientRequestIdAdapter
 /// </summary>
 /// <returns>The new DataServiceContext instance.</returns>
 public override IWebRequestAdapter CreateClientRequestIdAdapter()
 {
     if (_clientRequestIdAdapter == null)
     {
         _clientRequestIdAdapter = new ClientRequestIdAdapter();
     }
     return _clientRequestIdAdapter;
 }
コード例 #4
0
        private Uri GetAccountApiEndpoint(OAuthDataServiceAdapter dataServiceAdapter, ServiceVersionAdapter versionAdapter, Uri apiServer, UserAgentAdapter userAgentAdapter, IWebRequestAdapter clientRequestIdAdapter)
        {
            MediaRetryPolicy retryPolicy = new MediaRetryPolicy(
                GetWebRequestTransientErrorDetectionStrategy(),
                RetryStrategyFactory.DefaultStrategy());

            Uri apiEndpoint = null;

            retryPolicy.ExecuteAction(
                () =>
            {
                HttpWebRequest request    = (HttpWebRequest)WebRequest.Create(apiServer);
                request.AllowAutoRedirect = false;
                dataServiceAdapter.AddAccessTokenToRequest(request);
                versionAdapter.AddVersionToRequest(request);
                userAgentAdapter.AddUserAgentToRequest(request);
                clientRequestIdAdapter.AddClientRequestId(request);

                using (WebResponse response = request.GetResponse())
                {
                    apiEndpoint = GetAccountApiEndpointFromResponse(response);
                }
            }
                );

            return(apiEndpoint);
        }