PayPal.Api.ConfigManager.GetConfigWithDefaults C# (CSharp) Méthode

GetConfigWithDefaults() public static méthode

Creates new configuration that combines incoming configuration dictionary and defaults
public static GetConfigWithDefaults ( string>.Dictionary config ) : string>.Dictionary
config string>.Dictionary
Résultat string>.Dictionary
        public static Dictionary<string, string> GetConfigWithDefaults(Dictionary<string, string> config)
        {
            Dictionary<string, string> ret;
            if (config == null)
            {
                ret = new Dictionary<string, string>();
            }
            else
            {
                ret = new Dictionary<string, string>(config);
            }

            foreach (string key in ConfigManager.defaultConfig.Keys)
            {
                if (!ret.ContainsKey(key))
                {
                    ret.Add(key, ConfigManager.defaultConfig[key]);
                }
            }
            return ret;
        }

Usage Example

Exemple #1
0
        /// <summary>
        /// Client Id and Secret for the OAuth
        /// </summary>
        /// <param name="clientId"></param>
        /// <param name="clientSecret"></param>
        /// <param name="config"></param>
        public OAuthTokenCredential(string clientId = "", string clientSecret = "", Dictionary <string, string> config = null)
        {
            this.config = config != null?ConfigManager.GetConfigWithDefaults(config) : ConfigManager.GetConfigWithDefaults(ConfigManager.Instance.GetProperties());

            // Set the client ID.
            if (string.IsNullOrEmpty(clientId))
            {
                this.ClientId = this.config.ContainsKey(BaseConstants.ClientId) ? this.config[BaseConstants.ClientId] : string.Empty;
            }
            else
            {
                this.ClientId = clientId;
                this.config[BaseConstants.ClientId] = clientId;
            }

            // Set the client secret.
            if (string.IsNullOrEmpty(clientSecret))
            {
                this.ClientSecret = this.config.ContainsKey(BaseConstants.ClientSecret) ? this.config[BaseConstants.ClientSecret] : string.Empty;
            }
            else
            {
                this.ClientSecret = clientSecret;
                this.config[BaseConstants.ClientSecret] = clientSecret;
            }

            this.SdkVersion = new SDKVersion();
            this.AccessTokenExpirationSafetyGapInSeconds = 120; // Default is 2 minute safety gap for token expiration.
        }
All Usage Examples Of PayPal.Api.ConfigManager::GetConfigWithDefaults