@@ -28,18 +28,16 @@ public class ForceClientProxy : IForceClientProxy
2828 /// <param name="authenticationClient">Instance of <see cref="AuthenticationClientProxy"/> that creates instance of <see cref="AuthenticationClient"/>.</param>
2929 /// <param name="logger">Instance of the <see cref="ILogger{IForceClientProxy}"/>.</param>
3030 /// <param name="options">Options based on <see cref="SalesforceConfiguration"/></param>
31- public ForceClientProxy ( IAuthenticationClientProxy authenticationClient ,
31+ public ForceClientProxy (
32+ IAuthenticationClientProxy authenticationClient ,
3233 ILogger < ForceClientProxy > logger ,
3334 SalesforceConfiguration options )
3435 {
35- #region ArgumentException and ArgumentNullException
36-
3736 _options = options ?? throw new ArgumentNullException ( nameof ( options ) ) ;
3837
39- _authenticationClient = authenticationClient ??
40- throw new ArgumentNullException ( nameof ( authenticationClient ) ) ;
38+ _authenticationClient = authenticationClient ?? throw new ArgumentNullException ( nameof ( authenticationClient ) ) ;
39+
4140 _logger = logger ?? throw new ArgumentNullException ( nameof ( logger ) ) ;
42- #endregion
4341
4442 // creates an instance of the forceclient register as singleton
4543 _forceClient = new NetCoreForce . Client . ForceClient (
@@ -53,9 +51,6 @@ public ForceClientProxy(IAuthenticationClientProxy authenticationClient,
5351 nameof ( ForceClientProxy ) , OnWaitAndRetry ) ;
5452 }
5553
56-
57- #region Private
58-
5954 private async Task RefreshAuthorization ( )
6055 {
6156 await _authenticationClient . Authenticate ( ) ;
@@ -69,24 +64,27 @@ private async Task RefreshAuthorization()
6964 _logger . LogDebug ( $ "Salesforce Authentication Successful!") ;
7065 }
7166
72- private async Task OnWaitAndRetry ( Exception ex , int count , Context context )
67+ private async Task OnWaitAndRetry (
68+ Exception ex ,
69+ int count ,
70+ Context context )
7371 {
7472 _logger . LogWarning ( $ "Trying to { nameof ( RefreshAuthorization ) } ") ;
7573 _logger . LogWarning ( $ "Retry { context . Count } :{ count } of { context . PolicyKey } , due to { ex . Message } .") ;
7674 await RefreshAuthorization ( ) ;
7775 }
7876
79- private IAsyncPolicy CreateAuthenticationWaitAndRetry ( int retryAuthorization ,
80- string name ,
81- Func < Exception , int , Context , Task > retryHook )
77+ private IAsyncPolicy CreateAuthenticationWaitAndRetry (
78+ int retryAuthorization ,
79+ string name ,
80+ Func < Exception , int , Context , Task > retryHook )
8281 {
8382 return Policy
8483 . Handle < ForceApiException > ( x => x . Message . Contains ( "ErrorCode INVALID_SESSION_ID" ) )
85- . RetryAsync ( retryCount : retryAuthorization ,
86- onRetryAsync : retryHook )
87- . WithPolicyKey ( $ "{ name } Retry") ;
84+ . RetryAsync (
85+ retryCount : retryAuthorization ,
86+ onRetryAsync : retryHook ) . WithPolicyKey ( $ "{ name } Retry") ;
8887 }
89- #endregion
9088
9189 /// <summary>
9290 /// Retrieves a Salesforce object by its Id
@@ -96,8 +94,11 @@ private IAsyncPolicy CreateAuthenticationWaitAndRetry(int retryAuthorization,
9694 /// <param name="objectId">Id of the object to retrieve</param>
9795 /// <param name="token">Token to cancel operation</param>
9896 /// <param name="fields">List of fields to return.</param>
99- /// <returns>The retrieved object from salesforce.</returns>
100- public async Task < T > GetObjectById < T > ( string sObjectTypeName , string objectId , CancellationToken token ,
97+ /// <returns>The retrieved object from Salesforce.</returns>
98+ public async Task < T > GetObjectById < T > (
99+ string sObjectTypeName ,
100+ string objectId ,
101+ CancellationToken token ,
101102 List < string > fields = null )
102103 {
103104 return await _policy . ExecuteAsync ( ctx => _forceClient . GetObjectById < T > ( sObjectTypeName , objectId , fields ) , token ) ;
@@ -111,7 +112,9 @@ public async Task<T> GetObjectById<T>(string sObjectTypeName, string objectId, C
111112 /// <param name="instance">Object to create</param>
112113 /// <param name="headers">Optional request headers.</param>
113114 /// <returns>A <see cref="CreateResponse"/> representing the operation result.</returns>
114- public async Task < CreateResponse > CreateRecord < T > ( string sObjectTypeName , T instance ,
115+ public async Task < CreateResponse > CreateRecord < T > (
116+ string sObjectTypeName ,
117+ T instance ,
115118 Dictionary < string , string > headers = null )
116119 {
117120 return await _policy . ExecuteAsync ( ( ) => _forceClient . CreateRecord ( sObjectTypeName , instance , headers ) ) ;
@@ -126,8 +129,11 @@ public async Task<CreateResponse> CreateRecord<T>(string sObjectTypeName, T inst
126129 /// <param name="token">Token to cancel operation</param>
127130 /// <param name="headers">Optional request headers.</param>
128131 /// <returns>A <see cref="CreateResponse"/> representing the operation result.</returns>
129- public async Task < CreateResponse > CreateRecord < T > ( string sObjectTypeName , T instance ,
130- CancellationToken token , Dictionary < string , string > headers = null )
132+ public async Task < CreateResponse > CreateRecord < T > (
133+ string sObjectTypeName ,
134+ T instance ,
135+ CancellationToken token ,
136+ Dictionary < string , string > headers = null )
131137 {
132138 return await _policy . ExecuteAsync ( ctx => _forceClient . CreateRecord ( sObjectTypeName , instance , headers ) , token ) ;
133139 }
0 commit comments