Пример #1
0
        private string AppendDeleteByQueryParametersToPath(string path, DeleteByQueryParameters urlParameters)
        {
            if (urlParameters == null)
            {
                return(path);
            }

            var parameters = new List <string>();

            if (urlParameters.Replication != Replication.Sync)             //sync == default
            {
                parameters.Add("replication=" + urlParameters.Replication.ToString().ToLower());
            }

            if (urlParameters.Consistency != Consistency.Quorum)             //quorum == default
            {
                parameters.Add("consistency=" + urlParameters.Replication.ToString().ToLower());
            }

            if (!urlParameters.Routing.IsNullOrEmpty())
            {
                parameters.Add("routing=" + urlParameters.Routing);
            }

            path += "?" + string.Join("&", parameters.ToArray());
            return(path);
        }
Пример #2
0
        public void DeleteByQueryOverAllAsync <T>(string query, DeleteByQueryParameters parameters, Action <ConnectionStatus> callback) where T : class
        {
            query.ThrowIfNullOrEmpty("query");
            var path = this.CreatePath("_all");

            if (parameters != null && !parameters.Equals(default(DeleteByQueryParameters)))
            {
                path = this.AppendDeleteByQueryParametersToPath(path, parameters);
            }
            this._deleteToPathAsync(path, query, callback);
        }
Пример #3
0
        public ConnectionStatus DeleteByQueryOverAll <T>(string query, DeleteByQueryParameters parameters) where T : class
        {
            query.ThrowIfNullOrEmpty("query");
            var path = this.CreatePath("_all");

            if (parameters != null && !parameters.Equals(default(DeleteByQueryParameters)))
            {
                path = this.AppendDeleteByQueryParametersToPath(path, parameters);
            }
            return(this._deleteToPath(path, query));
        }
Пример #4
0
        public void DeleteByQueryAsync <T>(string query, string index, string type, DeleteByQueryParameters parameters, Action <ConnectionStatus> callback) where T : class
        {
            query.ThrowIfNullOrEmpty("query");
            index.ThrowIfNullOrEmpty("index cannot be empty");
            type.ThrowIfNullOrEmpty("type cannot be empty");
            var path = this.CreatePath(index, type);

            if (parameters != null && !parameters.Equals(default(DeleteByQueryParameters)))
            {
                path = this.AppendDeleteByQueryParametersToPath(path, parameters);
            }
            this._deleteToPathAsync(path, query, callback);
        }
Пример #5
0
        public ConnectionStatus DeleteByQuery <T>(string query, string index, DeleteByQueryParameters parameters) where T : class
        {
            query.ThrowIfNullOrEmpty("query");
            index.ThrowIfNullOrEmpty("index cannot be empty");

            var typeName = this.InferTypeName <T>();
            var path     = this.CreatePath(index, typeName);

            if (parameters != null && !parameters.Equals(default(DeleteByQueryParameters)))
            {
                path = this.AppendDeleteByQueryParametersToPath(path, parameters);
            }
            return(this._deleteToPath(path, query));
        }
Пример #6
0
        public void DeleteByQueryAsync <T>(string query, DeleteByQueryParameters parameters, Action <ConnectionStatus> callback) where T : class
        {
            query.ThrowIfNullOrEmpty("query");
            var index = this.Settings.DefaultIndex;

            index.ThrowIfNullOrEmpty("Cannot infer default index for current connection.");

            var typeName = this.InferTypeName <T>();
            var path     = this.CreatePath(index, typeName);

            if (parameters != null && !parameters.Equals(default(DeleteByQueryParameters)))
            {
                path = this.AppendDeleteByQueryParametersToPath(path, parameters);
            }
            this._deleteToPathAsync(path, query, callback);
        }
Пример #7
0
        public void DeleteByQueryOverIndicesAsync <T>(string query, IEnumerable <string> indices, IEnumerable <string> types,
                                                      DeleteByQueryParameters parameters, Action <ConnectionStatus> callback) where T : class
        {
            query.ThrowIfNullOrEmpty("query");
            if (indices == null || !indices.Any())
            {
                throw new ArgumentNullException("indices");
            }
            if (types == null || !types.Any())
            {
                throw new ArgumentNullException("types");
            }

            var indicesString = string.Join(",", indices.ToArray());
            var typesString   = string.Join(",", indices.ToArray());
            var path          = this.CreatePath(indicesString, typesString);

            if (parameters != null && !parameters.Equals(default(DeleteByQueryParameters)))
            {
                path = this.AppendDeleteByQueryParametersToPath(path, parameters);
            }
            this._deleteToPathAsync(path, query, callback);
        }
Пример #8
0
        public ConnectionStatus DeleteByQueryOverIndices <T>(string query, IEnumerable <string> indices, DeleteByQueryParameters parameters) where T : class
        {
            query.ThrowIfNullOrEmpty("query");
            if (indices == null || !indices.Any())
            {
                throw new ArgumentNullException("indices");
            }

            var indicesString = string.Join(",", indices.ToArray());
            var path          = this.CreatePath(indicesString);

            if (parameters != null && !parameters.Equals(default(DeleteByQueryParameters)))
            {
                path = this.AppendDeleteByQueryParametersToPath(path, parameters);
            }
            return(this._deleteToPath(path, query));
        }