ContainsKey() public method

public ContainsKey ( string key ) : bool
key string
return bool
Example #1
0
        public override Task <dynamic> ExecuteAsync()
        {
            if (!_imageIds.Any())
            {
                throw new SdkException(MustSpecifyAtLeastOneImageIdMessage);
            }

            var ids = string.Join(Comma, _imageIds);

            if (_imageIds.Count > 1)
            {
                QueryParameters.Add(IdsKey, ids);
                Path = ImageBatchPath;
            }
            else
            {
                Path = string.Format(ImagePath, ids);
            }

            if (_fields.Any())
            {
                if (QueryParameters.ContainsKey(FieldsKey))
                {
                    QueryParameters[FieldsKey] = _fields;
                }
                else
                {
                    QueryParameters.Add(FieldsKey, _fields);
                }
            }

            return(base.ExecuteAsync());
        }
Example #2
0
        public void TestContainsKeyTrueCase()
        {
            var query = "size";
            var qp    = new QueryParameters(query);

            Assert.True(qp.ContainsKey("size"));
        }
Example #3
0
        public void TestContainsKeyFalseCase()
        {
            var query = "size";
            var qp    = new QueryParameters(query);

            Assert.False(qp.ContainsKey("color"));
        }
        public void SetParameter(string parameterName, object?value)
        {
            Transaction transaction = Transaction.RunningTransaction;

            if (value is null)
            {
                AddOrSet(null);
            }
            else
            {
                AddOrSet(transaction.PersistenceProviderFactory.ConvertToStoredType(value.GetType(), value));
            }

            void AddOrSet(object?value)
            {
                if (QueryParameters.ContainsKey(parameterName))
                {
                    if (QueryParameters[parameterName].isConstant)
                    {
                        throw new NotSupportedException("You cannot set the value of a constant.");
                    }

                    QueryParameters[parameterName] = (value, false);
                }
                else
                {
                    QueryParameters.Add(parameterName, (value, false));
                }
            }
        }
        private static string GetEndpoint(string apiPath, out Dictionary <string, string> authHeaders, QueryParameters additionalParameters = null)
        {
            string baseEndPoint;

            authHeaders = null;
            if (ConfigDictionary.ContainsKey(LRConfigConstants.ApiRegion) && !string.IsNullOrWhiteSpace(ConfigDictionary[LRConfigConstants.ApiRegion]))
            {
                additionalParameters.Add("region", ConfigDictionary[LRConfigConstants.ApiRegion]);
            }
            if (apiPath.Contains("identity/v2") && additionalParameters.ContainsKey("apiSecret"))
            {
                additionalParameters.Remove("apiSecret");
                authHeaders = new Dictionary <string, string>
                {
                    [BaseConstants.AuthorizationHeader] = ConfigDictionary[LRConfigConstants.LoginRadiusApiSecret]
                };
            }
            else if (apiPath.Contains("/auth") && additionalParameters.ContainsKey("access_token"))
            {
                authHeaders = new Dictionary <string, string>
                {
                    [BaseConstants.AccessTokenAuthorizationHeader] = BaseConstants.AccessTokenBearerHeader + additionalParameters["access_token"]
                };
                additionalParameters.Remove("access_token");
            }
            else if (apiPath.Contains("identity/v2/auth/register") && additionalParameters.ContainsKey("sott"))
            {
                authHeaders = new Dictionary <string, string> {
                    [BaseConstants.SottAuthorizationHeader] = additionalParameters["sott"]
                };
                additionalParameters.Remove("sott");
            }

            if (apiPath.Contains("ciam/appinfo"))
            {
                baseEndPoint = BaseConstants.BaseConfigApiEndpoint;
            }
            else
            {
                baseEndPoint = string.IsNullOrWhiteSpace(ConfigDictionary[LRConfigConstants.DomainName])
               ? BaseConstants.BaseRestApiEndpoint : ConfigDictionary[LRConfigConstants.DomainName];
            }

            return(string.IsNullOrWhiteSpace(apiPath)
                ? $"{baseEndPoint}{additionalParameters.ToUrlFormattedString()}": $"{baseEndPoint}{apiPath}{additionalParameters.ToUrlFormattedString()}");
        }
Example #6
0
        public void AddQueryParameter(string key, string value)
        {
            if (!QueryParameters.ContainsKey(key))
            {
                QueryParameters.Add(key, new List <string>());
            }

            QueryParameters[key].Add(value);
        }
 private void AddQueryParameter(string key, object value)
 {
     if (QueryParameters.ContainsKey(key))
     {
         QueryParameters[key] = value;
     }
     else
     {
         QueryParameters.Add(key, value);
     }
 }
Example #8
0
 public void AddQueryParameter(string name, string value)
 {
     if (!QueryParameters.ContainsKey(name))
     {
         QueryParameters.Add(name, value);
     }
     else
     {
         QueryParameters[name] = value;
     }
 }
        public virtual SearchImages WithLicenseModel(LicenseModel value)
        {
            if (QueryParameters.ContainsKey(LicenseModelsKey))
            {
                QueryParameters[LicenseModelsKey] = value == LicenseModel.None
                    ? value
                    : (LicenseModel)QueryParameters[LicenseModelsKey] | value;
            }
            else
            {
                QueryParameters.Add(LicenseModelsKey, value);
            }

            return(this);
        }
        public SearchImages WithOrientation(Orientation value)
        {
            if (QueryParameters.ContainsKey(OrientationsKey))
            {
                QueryParameters[OrientationsKey] = value == Orientation.None
                    ? value
                    : (Orientation)QueryParameters[OrientationsKey] | value;
            }
            else
            {
                QueryParameters.Add(OrientationsKey, value);
            }

            return(this);
        }
        public SearchImages WithGraphicalStyle(GraphicalStyles value)
        {
            if (QueryParameters.ContainsKey(GraphicalStylesKey))
            {
                QueryParameters[GraphicalStylesKey] = value == GraphicalStyles.None
                    ? value
                    : (GraphicalStyles)QueryParameters[GraphicalStylesKey] | value;
            }
            else
            {
                QueryParameters.Add(GraphicalStylesKey, value);
            }

            return(this);
        }
        public SearchImages WithResponseFields(IList <string> value)
        {
            if (!QueryParameters.ContainsKey(FieldsKey))
            {
                QueryParameters.Add(FieldsKey, value);
            }
            else
            {
                var fields = QueryParameters[FieldsKey] as IEnumerable <string>;
                fields = fields.Union(value).Distinct();
                QueryParameters[FieldsKey] = fields.ToList();
            }

            return(this);
        }
        public override async Task <dynamic> ExecuteAsync()
        {
            if (!QueryParameters.ContainsKey(PhraseKey) ||
                string.IsNullOrWhiteSpace(QueryParameters[PhraseKey].ToString()))
            {
                throw new SdkException(PhraseIsRequired);
            }

            Method = "GET";
            Path   = string.IsNullOrEmpty(AssetType) ? V3SearchImagesPath : V3SearchImagesPath + "/" + AssetType;

            if (Fields.Any())
            {
                AddQueryParameter(FieldsKey, Fields);
            }

            return(await base.ExecuteAsync());
        }
        public SearchImages WithResponseField(string value)
        {
            if (!QueryParameters.ContainsKey(FieldsKey))
            {
                QueryParameters.Add(FieldsKey, new List <string> {
                    value
                });
            }
            else
            {
                var fields = (IList <string>)QueryParameters[FieldsKey];
                if (!fields.Contains(value))
                {
                    fields.Add(value);
                }
            }

            return(this);
        }
 public string GetQueryParameter(string parameter)
 {
     return(QueryParameters.ContainsKey(parameter) ? QueryParameters[parameter] : string.Empty);
 }