/// <summary> /// Consists the context. /// </summary> /// <param name="token">The token.</param> /// <param name="setting">The setting.</param> /// <param name="ipAddress">The ip address.</param> /// <param name="userAgent">The user agent.</param> /// <param name="cultureCode">The culture code.</param> /// <param name="currentUri">The current URI.</param> /// <param name="basicAuthentication">The basic authentication.</param> /// <param name="apiUniqueIdentifier">The API unique identifier.</param> internal static void ConsistContext(string token, RestApiSettings setting, string ipAddress, string userAgent, string cultureCode, Uri currentUri, HttpCredential basicAuthentication, ApiUniqueIdentifier apiUniqueIdentifier) { IRestApiEventHandlers restApiEventHandlers = setting?.EventHandlers; var apiContext = ContextHelper.ApiContext; apiContext.UserAgent = userAgent; apiContext.IpAddress = ipAddress; apiContext.CultureCode = cultureCode; apiContext.CurrentUri = currentUri; apiContext.HttpAuthorization = basicAuthentication; apiContext.UniqueIdentifier = apiUniqueIdentifier; if (restApiEventHandlers != null && !string.IsNullOrWhiteSpace(token)) { apiContext.CurrentCredential = restApiEventHandlers.GetCredentialByToken(token); apiContext.Token = token; } else { apiContext.CurrentCredential = null; apiContext.Token = null; } }
/// <summary> /// Consists the context. /// </summary> /// <param name="token">The token.</param> /// <param name="settingName">Name of the setting.</param> /// <param name="ipAddress">The ip address.</param> /// <param name="userAgent">The user agent.</param> /// <param name="cultureCode">The culture code.</param> /// <param name="currentUri">The current URI.</param> /// <param name="basicAuthentication">The basic authentication.</param> /// <param name="apiUniqueIdentifier">The API unique identifier.</param> internal static void ConsistContext(string token, string settingName, string ipAddress, string userAgent, string cultureCode, Uri currentUri, HttpCredential basicAuthentication, ApiUniqueIdentifier apiUniqueIdentifier) { ConsistContext(token, RestApiSettingPool.GetRestApiSettingByName(settingName, true), ipAddress, userAgent, cultureCode, currentUri, basicAuthentication, apiUniqueIdentifier); }