style: clean code

This commit is contained in:
Fu Diwei
2021-10-18 18:29:07 +08:00
parent 8666ec882f
commit d3007394ad
13 changed files with 34 additions and 34 deletions

View File

@@ -26,7 +26,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
if (client is null) throw new ArgumentNullException(nameof(client)); if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request)); if (request is null) throw new ArgumentNullException(nameof(request));
if (!request.AgentId.HasValue) if (request.AgentId == null)
request.AgentId = client.Credentials.AgentId; request.AgentId = client.Credentials.AgentId;
IFlurlRequest flurlReq = client IFlurlRequest flurlReq = client
@@ -72,7 +72,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
if (client is null) throw new ArgumentNullException(nameof(client)); if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request)); if (request is null) throw new ArgumentNullException(nameof(request));
if (!request.AgentId.HasValue) if (request.AgentId == null)
request.AgentId = client.Credentials.AgentId; request.AgentId = client.Credentials.AgentId;
IFlurlRequest flurlReq = client IFlurlRequest flurlReq = client
@@ -96,7 +96,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
if (client is null) throw new ArgumentNullException(nameof(client)); if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request)); if (request is null) throw new ArgumentNullException(nameof(request));
if (!request.AgentId.HasValue) if (request.AgentId == null)
request.AgentId = client.Credentials.AgentId; request.AgentId = client.Credentials.AgentId;
IFlurlRequest flurlReq = client IFlurlRequest flurlReq = client
@@ -121,7 +121,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
if (client is null) throw new ArgumentNullException(nameof(client)); if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request)); if (request is null) throw new ArgumentNullException(nameof(request));
if (!request.AgentId.HasValue) if (request.AgentId == null)
request.AgentId = client.Credentials.AgentId; request.AgentId = client.Credentials.AgentId;
IFlurlRequest flurlReq = client IFlurlRequest flurlReq = client
@@ -145,7 +145,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
if (client is null) throw new ArgumentNullException(nameof(client)); if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request)); if (request is null) throw new ArgumentNullException(nameof(request));
if (!request.AgentId.HasValue) if (request.AgentId == null)
request.AgentId = client.Credentials.AgentId; request.AgentId = client.Credentials.AgentId;
IFlurlRequest flurlReq = client IFlurlRequest flurlReq = client
@@ -169,7 +169,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
if (client is null) throw new ArgumentNullException(nameof(client)); if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request)); if (request is null) throw new ArgumentNullException(nameof(request));
if (!request.AgentId.HasValue) if (request.AgentId == null)
request.AgentId = client.Credentials.AgentId; request.AgentId = client.Credentials.AgentId;
IFlurlRequest flurlReq = client IFlurlRequest flurlReq = client

View File

@@ -28,7 +28,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
.CreateRequest(request, HttpMethod.Get, "cgi-bin", "corp", "get_join_qrcode") .CreateRequest(request, HttpMethod.Get, "cgi-bin", "corp", "get_join_qrcode")
.SetQueryParam("access_token", request.AccessToken); .SetQueryParam("access_token", request.AccessToken);
if (request.SizeType.HasValue) if (request.SizeType != null)
flurlReq.SetQueryParam("size_type", request.SizeType.Value); flurlReq.SetQueryParam("size_type", request.SizeType.Value);
return await client.SendRequestWithJsonAsync<Models.CgibinCorpGetJoinQrcodeResponse>(flurlReq, cancellationToken: cancellationToken); return await client.SendRequestWithJsonAsync<Models.CgibinCorpGetJoinQrcodeResponse>(flurlReq, cancellationToken: cancellationToken);

View File

@@ -25,7 +25,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
if (client is null) throw new ArgumentNullException(nameof(client)); if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request)); if (request is null) throw new ArgumentNullException(nameof(request));
if (!request.ParentAgentId.HasValue) if (request.ParentAgentId == null)
request.ParentAgentId = client.Credentials.AgentId; request.ParentAgentId = client.Credentials.AgentId;
IFlurlRequest flurlReq = client IFlurlRequest flurlReq = client

View File

@@ -97,7 +97,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
.CreateRequest(request, HttpMethod.Get, "cgi-bin", "department", "list") .CreateRequest(request, HttpMethod.Get, "cgi-bin", "department", "list")
.SetQueryParam("access_token", request.AccessToken); .SetQueryParam("access_token", request.AccessToken);
if (request.ParentDepartmentId.HasValue) if (request.ParentDepartmentId != null)
flurlReq.SetQueryParam("id", request.ParentDepartmentId.Value); flurlReq.SetQueryParam("id", request.ParentDepartmentId.Value);
return await client.SendRequestWithJsonAsync<Models.CgibinDepartmentListResponse>(flurlReq, cancellationToken: cancellationToken); return await client.SendRequestWithJsonAsync<Models.CgibinDepartmentListResponse>(flurlReq, cancellationToken: cancellationToken);

View File

@@ -1008,7 +1008,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
if (client is null) throw new ArgumentNullException(nameof(client)); if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request)); if (request is null) throw new ArgumentNullException(nameof(request));
if (!request.AgentId.HasValue) if (request.AgentId == null)
request.AgentId = client.Credentials.AgentId; request.AgentId = client.Credentials.AgentId;
IFlurlRequest flurlReq = client IFlurlRequest flurlReq = client

View File

@@ -125,7 +125,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
if (client is null) throw new ArgumentNullException(nameof(client)); if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request)); if (request is null) throw new ArgumentNullException(nameof(request));
if (!request.AgentId.HasValue) if (request.AgentId == null)
request.AgentId = client.Credentials.AgentId; request.AgentId = client.Credentials.AgentId;
IFlurlRequest flurlReq = client IFlurlRequest flurlReq = client

View File

@@ -30,7 +30,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
const string TYPE_VOICE = "voice"; const string TYPE_VOICE = "voice";
const string TYPE_VIDEO = "video"; const string TYPE_VIDEO = "video";
if (string.IsNullOrEmpty(request.FileName)) if (request.FileName == null)
{ {
string ext = ""; string ext = "";
if (TYPE_IMAGE.Equals(request.Type)) if (TYPE_IMAGE.Equals(request.Type))
@@ -43,7 +43,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
request.FileName = Guid.NewGuid().ToString("N").ToLower() + ext; request.FileName = Guid.NewGuid().ToString("N").ToLower() + ext;
} }
if (string.IsNullOrEmpty(request.FileContentType)) if (request.FileContentType == null)
{ {
if (TYPE_IMAGE.Equals(request.Type)) if (TYPE_IMAGE.Equals(request.Type))
request.FileContentType = Utilities.FileNameToContentTypeMapper.GetContentTypeForImage(request.FileName!) ?? "image/png"; request.FileContentType = Utilities.FileNameToContentTypeMapper.GetContentTypeForImage(request.FileName!) ?? "image/png";
@@ -86,10 +86,10 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
if (client is null) throw new ArgumentNullException(nameof(client)); if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request)); if (request is null) throw new ArgumentNullException(nameof(request));
if (string.IsNullOrEmpty(request.FileName)) if (request.FileName == null)
request.FileName = Guid.NewGuid().ToString("N").ToLower() + ".png"; request.FileName = Guid.NewGuid().ToString("N").ToLower() + ".png";
if (string.IsNullOrEmpty(request.FileContentType)) if (request.FileContentType == null)
request.FileContentType = Utilities.FileNameToContentTypeMapper.GetContentTypeForImage(request.FileName!) ?? "image/png"; request.FileContentType = Utilities.FileNameToContentTypeMapper.GetContentTypeForImage(request.FileName!) ?? "image/png";
IFlurlRequest flurlReq = client IFlurlRequest flurlReq = client
@@ -125,7 +125,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
const string TYPE_VIDEO = "video"; const string TYPE_VIDEO = "video";
const string TYPE_FILE = "file"; const string TYPE_FILE = "file";
if (string.IsNullOrEmpty(request.FileName)) if (request.FileName == null)
{ {
string ext = ""; string ext = "";
if (TYPE_IMAGE.Equals(request.Type)) if (TYPE_IMAGE.Equals(request.Type))
@@ -138,7 +138,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
request.FileName = Guid.NewGuid().ToString("N").ToLower() + ext; request.FileName = Guid.NewGuid().ToString("N").ToLower() + ext;
} }
if (string.IsNullOrEmpty(request.FileContentType)) if (request.FileContentType == null)
{ {
if (TYPE_IMAGE.Equals(request.Type)) if (TYPE_IMAGE.Equals(request.Type))
request.FileContentType = Utilities.FileNameToContentTypeMapper.GetContentTypeForImage(request.FileName!) ?? "image/png"; request.FileContentType = Utilities.FileNameToContentTypeMapper.GetContentTypeForImage(request.FileName!) ?? "image/png";

View File

@@ -24,7 +24,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
if (client is null) throw new ArgumentNullException(nameof(client)); if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request)); if (request is null) throw new ArgumentNullException(nameof(request));
if (!request.AgentId.HasValue) if (request.AgentId == null)
request.AgentId = client.Credentials.AgentId; request.AgentId = client.Credentials.AgentId;
IFlurlRequest flurlReq = client IFlurlRequest flurlReq = client
@@ -48,7 +48,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
if (client is null) throw new ArgumentNullException(nameof(client)); if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request)); if (request is null) throw new ArgumentNullException(nameof(request));
if (!request.AgentId.HasValue) if (request.AgentId == null)
request.AgentId = client.Credentials.AgentId; request.AgentId = client.Credentials.AgentId;
IFlurlRequest flurlReq = client IFlurlRequest flurlReq = client
@@ -72,7 +72,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
if (client is null) throw new ArgumentNullException(nameof(client)); if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request)); if (request is null) throw new ArgumentNullException(nameof(request));
if (!request.AgentId.HasValue) if (request.AgentId == null)
request.AgentId = client.Credentials.AgentId; request.AgentId = client.Credentials.AgentId;
IFlurlRequest flurlReq = client IFlurlRequest flurlReq = client

View File

@@ -26,7 +26,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
if (client is null) throw new ArgumentNullException(nameof(client)); if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request)); if (request is null) throw new ArgumentNullException(nameof(request));
if (!request.AgentId.HasValue) if (request.AgentId == null)
request.AgentId = client.Credentials.AgentId; request.AgentId = client.Credentials.AgentId;
IFlurlRequest flurlReq = client IFlurlRequest flurlReq = client
@@ -50,7 +50,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
if (client is null) throw new ArgumentNullException(nameof(client)); if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request)); if (request is null) throw new ArgumentNullException(nameof(request));
if (!request.AgentId.HasValue) if (request.AgentId == null)
request.AgentId = client.Credentials.AgentId; request.AgentId = client.Credentials.AgentId;
IFlurlRequest flurlReq = client IFlurlRequest flurlReq = client
@@ -74,7 +74,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
if (client is null) throw new ArgumentNullException(nameof(client)); if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request)); if (request is null) throw new ArgumentNullException(nameof(request));
if (!request.AgentId.HasValue) if (request.AgentId == null)
request.AgentId = client.Credentials.AgentId; request.AgentId = client.Credentials.AgentId;
IFlurlRequest flurlReq = client IFlurlRequest flurlReq = client

View File

@@ -135,7 +135,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
.SetQueryParam("access_token", request.AccessToken) .SetQueryParam("access_token", request.AccessToken)
.SetQueryParam("department_id", request.DeparmentId); .SetQueryParam("department_id", request.DeparmentId);
if (request.RequireFetchChild.HasValue) if (request.RequireFetchChild != null)
flurlReq.SetQueryParam("fetch_child", request.RequireFetchChild.Value ? 1 : 0); flurlReq.SetQueryParam("fetch_child", request.RequireFetchChild.Value ? 1 : 0);
return await client.SendRequestWithJsonAsync<Models.CgibinSchoolUserListResponse>(flurlReq, cancellationToken: cancellationToken); return await client.SendRequestWithJsonAsync<Models.CgibinSchoolUserListResponse>(flurlReq, cancellationToken: cancellationToken);
@@ -566,7 +566,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
.CreateRequest(request, HttpMethod.Get, "cgi-bin", "school", "department", "list") .CreateRequest(request, HttpMethod.Get, "cgi-bin", "school", "department", "list")
.SetQueryParam("access_token", request.AccessToken); .SetQueryParam("access_token", request.AccessToken);
if (request.ParentDepartmentId.HasValue) if (request.ParentDepartmentId != null)
flurlReq.SetQueryParam("id", request.ParentDepartmentId); flurlReq.SetQueryParam("id", request.ParentDepartmentId);
return await client.SendRequestWithJsonAsync<Models.CgibinSchoolDepartmentListResponse>(flurlReq, cancellationToken: cancellationToken); return await client.SendRequestWithJsonAsync<Models.CgibinSchoolDepartmentListResponse>(flurlReq, cancellationToken: cancellationToken);

View File

@@ -46,10 +46,10 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
if (client is null) throw new ArgumentNullException(nameof(client)); if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request)); if (request is null) throw new ArgumentNullException(nameof(request));
if (string.IsNullOrEmpty(request.SuiteId)) if (request.SuiteId == null)
request.SuiteId = client.Credentials.SuiteId; request.SuiteId = client.Credentials.SuiteId;
if (string.IsNullOrEmpty(request.SuiteSecret)) if (request.SuiteSecret == null)
request.SuiteSecret = client.Credentials.SuiteSecret; request.SuiteSecret = client.Credentials.SuiteSecret;
IFlurlRequest flurlReq = client IFlurlRequest flurlReq = client
@@ -246,7 +246,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
const string TYPE_VOICE = "voice"; const string TYPE_VOICE = "voice";
const string TYPE_VIDEO = "video"; const string TYPE_VIDEO = "video";
if (string.IsNullOrEmpty(request.FileName)) if (request.FileName == null)
{ {
string ext = ""; string ext = "";
if (TYPE_IMAGE.Equals(request.Type)) if (TYPE_IMAGE.Equals(request.Type))
@@ -259,7 +259,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
request.FileName = Guid.NewGuid().ToString("N").ToLower() + ext; request.FileName = Guid.NewGuid().ToString("N").ToLower() + ext;
} }
if (string.IsNullOrEmpty(request.FileContentType)) if (request.FileContentType == null)
{ {
if (TYPE_IMAGE.Equals(request.Type)) if (TYPE_IMAGE.Equals(request.Type))
request.FileContentType = Utilities.FileNameToContentTypeMapper.GetContentTypeForImage(request.FileName!) ?? "image/png"; request.FileContentType = Utilities.FileNameToContentTypeMapper.GetContentTypeForImage(request.FileName!) ?? "image/png";

View File

@@ -143,7 +143,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
.SetQueryParam("access_token", request.AccessToken) .SetQueryParam("access_token", request.AccessToken)
.SetQueryParam("department_id", request.DepartmentId); .SetQueryParam("department_id", request.DepartmentId);
if (request.RequireFetchChild.HasValue) if (request.RequireFetchChild != null)
flurlReq.SetQueryParam("fetch_child", request.RequireFetchChild.Value ? 1 : 0); flurlReq.SetQueryParam("fetch_child", request.RequireFetchChild.Value ? 1 : 0);
return await client.SendRequestWithJsonAsync<Models.CgibinUserSimpleListResponse>(flurlReq, cancellationToken: cancellationToken); return await client.SendRequestWithJsonAsync<Models.CgibinUserSimpleListResponse>(flurlReq, cancellationToken: cancellationToken);
@@ -169,7 +169,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
.SetQueryParam("access_token", request.AccessToken) .SetQueryParam("access_token", request.AccessToken)
.SetQueryParam("department_id", request.DepartmentId); .SetQueryParam("department_id", request.DepartmentId);
if (request.RequireFetchChild.HasValue) if (request.RequireFetchChild != null)
flurlReq.SetQueryParam("fetch_child", request.RequireFetchChild.Value ? 1 : 0); flurlReq.SetQueryParam("fetch_child", request.RequireFetchChild.Value ? 1 : 0);
return await client.SendRequestWithJsonAsync<Models.CgibinUserListResponse>(flurlReq, cancellationToken: cancellationToken); return await client.SendRequestWithJsonAsync<Models.CgibinUserListResponse>(flurlReq, cancellationToken: cancellationToken);
@@ -324,10 +324,10 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
.CreateRequest(request, HttpMethod.Get, "cgi-bin", "user", "list_member_auth") .CreateRequest(request, HttpMethod.Get, "cgi-bin", "user", "list_member_auth")
.SetQueryParam("access_token", request.AccessToken); .SetQueryParam("access_token", request.AccessToken);
if (!string.IsNullOrEmpty(request.NextCursor)) if (request.NextCursor != null)
flurlReq.SetQueryParam("cursor", request.NextCursor); flurlReq.SetQueryParam("cursor", request.NextCursor);
if (request.Limit.HasValue) if (request.Limit != null)
flurlReq.SetQueryParam("limit", request.Limit); flurlReq.SetQueryParam("limit", request.Limit);
return await client.SendRequestWithJsonAsync<Models.CgibinUserListMemberAuthResponse>(flurlReq, cancellationToken: cancellationToken); return await client.SendRequestWithJsonAsync<Models.CgibinUserListMemberAuthResponse>(flurlReq, cancellationToken: cancellationToken);

View File

@@ -59,7 +59,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
{ {
IFlurlRequest flurlRequest = FlurlClient.Request(urlSegments).WithVerb(method); IFlurlRequest flurlRequest = FlurlClient.Request(urlSegments).WithVerb(method);
if (request.Timeout.HasValue) if (request.Timeout != null)
{ {
flurlRequest.WithTimeout(TimeSpan.FromMilliseconds(request.Timeout.Value)); flurlRequest.WithTimeout(TimeSpan.FromMilliseconds(request.Timeout.Value));
} }