From a3d477075ab2c097b99267fff53631dd1ad2f552 Mon Sep 17 00:00:00 2001 From: oneRain Date: Wed, 7 Aug 2019 14:32:00 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=95=B4=E7=90=86=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Storage/Storage/Public/AVQuery.cs | 35 +++++++++++++------------------ 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/Storage/Storage/Public/AVQuery.cs b/Storage/Storage/Public/AVQuery.cs index e99d33c..6c9a8cb 100644 --- a/Storage/Storage/Public/AVQuery.cs +++ b/Storage/Storage/Public/AVQuery.cs @@ -255,11 +255,9 @@ namespace LeanCloud /// CQL 语句 /// CancellationToken /// 返回符合条件的对象集合 - public static Task> DoCloudQueryAsync(string cql, CancellationToken cancellationToken) - { - var queryString = string.Format("cloudQuery?cql={0}", Uri.EscapeDataString(cql)); - - return rebuildObjectFromCloudQueryResult(queryString); + public static Task> DoCloudQueryAsync(string cql, CancellationToken cancellationToken) { + var queryString = $"cloudQuery?cql={Uri.EscapeDataString(cql)}"; + return RebuildObjectFromCloudQueryResult(queryString); } /// @@ -267,8 +265,7 @@ namespace LeanCloud /// /// /// - public static Task> DoCloudQueryAsync(string cql) - { + public static Task> DoCloudQueryAsync(string cql) { return DoCloudQueryAsync(cql, CancellationToken.None); } @@ -278,17 +275,15 @@ namespace LeanCloud /// 带有占位符的模板 cql 语句 /// 占位符对应的参数数组 /// - public static Task> DoCloudQueryAsync(string cqlTeamplate, params object[] pvalues) - { + public static Task> DoCloudQueryAsync(string cqlTeamplate, params object[] pvalues) { string queryStringTemplate = "cloudQuery?cql={0}&pvalues={1}"; string pSrting = JsonConvert.SerializeObject(pvalues); string queryString = string.Format(queryStringTemplate, Uri.EscapeDataString(cqlTeamplate), Uri.EscapeDataString(pSrting)); - return rebuildObjectFromCloudQueryResult(queryString); + return RebuildObjectFromCloudQueryResult(queryString); } - internal static Task> rebuildObjectFromCloudQueryResult(string queryString) - { + internal static Task> RebuildObjectFromCloudQueryResult(string queryString) { var command = new AVCommand { Path = queryString, Method = HttpMethod.Get @@ -383,12 +378,12 @@ namespace LeanCloud var other = obj as AVQuery; return ClassName.Equals(other.ClassName) && - this.where.CollectionsEqual(other.where) && - this.orderBy.CollectionsEqual(other.orderBy) && - this.includes.CollectionsEqual(other.includes) && - this.selectedKeys.CollectionsEqual(other.selectedKeys) && - object.Equals(this.skip, other.skip) && - object.Equals(this.limit, other.limit); + where.CollectionsEqual(other.where) && + orderBy.CollectionsEqual(other.orderBy) && + includes.CollectionsEqual(other.includes) && + selectedKeys.CollectionsEqual(other.selectedKeys) && + Equals(skip, other.skip) && + Equals(limit, other.limit); } public override int GetHashCode() { @@ -554,7 +549,7 @@ namespace LeanCloud "Only ECMAScript-compatible regexes are supported. Please use the ECMAScript RegexOptions flag when creating your regex."); } MergeWhereClauses(new Dictionary { - { key, new Dictionary{ { key, EncodeRegex(regex, modifiers) } } } + { key, EncodeRegex(regex, modifiers) } }); return this; } @@ -563,7 +558,7 @@ namespace LeanCloud return WhereMatches(key, regex, null); } - public AVQuery WhereMatches(string key, string pattern, string modifiers = null) { + public AVQuery WhereMatches(string key, string pattern, string modifiers) { return WhereMatches(key, new Regex(pattern, RegexOptions.ECMAScript), modifiers); }