Skip to content

Commit f73cb14

Browse files
committed
更新使用新的c#语法
1 parent f0baafa commit f73cb14

37 files changed

+165
-280
lines changed

WebApiClient.Analyzers/WebApiClient.Analyzers.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<Version>1.0.0</Version>
4+
<Version>1.0.0-beta4</Version>
55
<TargetFramework>netstandard1.1</TargetFramework>
66
<PackageTargetFallback>portable-net45+win8</PackageTargetFallback>
7-
<Configurations>JIT_Debug;JIT_Release;AOT_Debug;AOT_Release</Configurations>
7+
<Configurations>JIT_Debug;JIT_Release;AOT_Debug;AOT_Release</Configurations>
88
<DEBUGRELEASE Condition="'$(Configuration)' == 'AOT_Debug' Or '$(Configuration)' == 'JIT_Debug'">TRACE;DEBUG</DEBUGRELEASE>
99
<DEBUGRELEASE Condition="'$(Configuration)' == 'AOT_Release' Or '$(Configuration)' == 'JIT_Release'">TRACE;RELEASE</DEBUGRELEASE>
1010

1111
<DefineConstants>$(JITAOT);$(DEBUGRELEASE)</DefineConstants>
1212
</PropertyGroup>
13-
13+
1414
<PropertyGroup Condition="'$(DEBUGRELEASE)'=='TRACE;DEBUG'">
1515
<Optimize>false</Optimize>
1616
</PropertyGroup>

WebApiClient/Attributes/FilterAttributes/ApiActionFilterAttribute.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ public abstract class ApiActionFilterAttribute : Attribute, IApiActionFilterAttr
2525
/// </summary>
2626
public bool AllowMultiple
2727
{
28-
get
29-
{
30-
return this.GetType().IsAllowMultiple();
31-
}
28+
get => this.GetType().IsAllowMultiple();
3229
}
3330

3431
/// <summary>

WebApiClient/Attributes/HttpActionAttributes/ApiActionAttribute.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,14 @@ public abstract class ApiActionAttribute : Attribute, IApiActionAttribute
1313
/// <summary>
1414
/// 获取顺序排序索引
1515
/// </summary>
16-
public virtual int OrderIndex { get; private set; }
16+
public virtual int OrderIndex { get; }
1717

1818
/// <summary>
1919
/// 获取本类型是否允许在接口与方法上重复
2020
/// </summary>
2121
public bool AllowMultiple
2222
{
23-
get
24-
{
25-
return this.GetType().IsAllowMultiple();
26-
}
23+
get => this.GetType().IsAllowMultiple();
2724
}
2825

2926
/// <summary>

WebApiClient/Attributes/HttpActionAttributes/HttpHostAttribute.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,15 @@ public class HttpHostAttribute : ApiActionAttribute
1515
/// <summary>
1616
/// 获取根路径
1717
/// </summary>
18-
public Uri Host { get; private set; }
18+
public Uri Host { get; }
1919

2020
/// <summary>
2121
/// 获取顺序排序索引
2222
/// int.MinValue
2323
/// </summary>
2424
public override int OrderIndex
2525
{
26-
get
27-
{
28-
return int.MinValue;
29-
}
26+
get => int.MaxValue;
3027
}
3128

3229
/// <summary>

WebApiClient/Attributes/HttpActionAttributes/HttpMethodAttribute.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,20 @@ public class HttpMethodAttribute : ApiActionAttribute
1616
/// <summary>
1717
/// 获取请求方法
1818
/// </summary>
19-
public HttpMethod Method { get; private set; }
19+
public HttpMethod Method { get; }
2020

2121
/// <summary>
2222
/// 获取请求相对路径
2323
/// </summary>
24-
public string Path { get; private set; }
24+
public string Path { get; }
2525

2626
/// <summary>
2727
/// 获取顺序排序索引
2828
/// 优先级最高
2929
/// </summary>
3030
public override int OrderIndex
3131
{
32-
get
33-
{
34-
return int.MinValue + 1;
35-
}
32+
get => int.MinValue + 1;
3633
}
3734

3835
/// <summary>

WebApiClient/Attributes/ParameterAttributes/JsonContentAttribute.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,8 @@ public class JsonContentAttribute : HttpContentAttribute, IDateTimeFormatable, I
2121
/// <exception cref="ArgumentException"></exception>
2222
public string Encoding
2323
{
24-
get
25-
{
26-
return this.encoding.WebName;
27-
}
28-
set
29-
{
30-
this.encoding = System.Text.Encoding.GetEncoding(value);
31-
}
24+
get => this.encoding.WebName;
25+
set => this.encoding = System.Text.Encoding.GetEncoding(value);
3226
}
3327

3428
/// <summary>

WebApiClient/Attributes/ParameterAttributes/PathQueryAttribute.cs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Linq;
43
using System.Text;
54
using System.Threading.Tasks;
65
using WebApiClient.Contexts;
@@ -25,14 +24,8 @@ public class PathQueryAttribute : Attribute, IApiParameterAttribute, IIgnoreWhen
2524
/// <exception cref="ArgumentException"></exception>
2625
public string Encoding
2726
{
28-
get
29-
{
30-
return this.encoding.WebName;
31-
}
32-
set
33-
{
34-
this.encoding = System.Text.Encoding.GetEncoding(value);
35-
}
27+
get => this.encoding.WebName;
28+
set => this.encoding = System.Text.Encoding.GetEncoding(value);
3629
}
3730

3831
/// <summary>

WebApiClient/Attributes/ParameterAttributes/RawStringContentAttribute.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,8 @@ public class RawStringContentAttribute : HttpContentAttribute, IEncodingable
2626
/// <exception cref="ArgumentException"></exception>
2727
public string Encoding
2828
{
29-
get
30-
{
31-
return this.encoding.WebName;
32-
}
33-
set
34-
{
35-
this.encoding = System.Text.Encoding.GetEncoding(value);
36-
}
29+
get => this.encoding.WebName;
30+
set => this.encoding = System.Text.Encoding.GetEncoding(value);
3731
}
3832

3933
/// <summary>

WebApiClient/Attributes/ParameterAttributes/XmlContentAttribute.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,8 @@ public class XmlContentAttribute : HttpContentAttribute, IEncodingable
2020
/// <exception cref="ArgumentException"></exception>
2121
public string Encoding
2222
{
23-
get
24-
{
25-
return this.encoding.WebName;
26-
}
27-
set
28-
{
29-
this.encoding = System.Text.Encoding.GetEncoding(value);
30-
}
23+
get => this.encoding.WebName;
24+
set => this.encoding = System.Text.Encoding.GetEncoding(value);
3125
}
3226

3327
/// <summary>

WebApiClient/Attributes/TimeoutAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class TimeoutAttribute : ApiActionAttribute, IApiParameterAttribute
1616
/// <summary>
1717
/// 获取超时时间
1818
/// </summary>
19-
public TimeSpan? TimeSpan { get; private set; }
19+
public TimeSpan? TimeSpan { get; }
2020

2121
/// <summary>
2222
/// 表示将参数值作为请求的超时时间

0 commit comments

Comments
 (0)