Skip to content

Commit 89a8127

Browse files
committed
refactor: 使用 readonly struct
1 parent a5c1f91 commit 89a8127

File tree

5 files changed

+10
-12
lines changed

5 files changed

+10
-12
lines changed

CSharp-OpenBMCLAPI/Modules/ClusterInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/// <summary>
44
/// 负责存储 Cluster 的 secret 和 id
55
/// </summary>
6-
public struct ClusterInfo(string id, string secret)
6+
public readonly struct ClusterInfo(string id, string secret)
77
{
88
public readonly string clusterId = id;
99
public readonly string clusterSecret = secret;

CSharp-OpenBMCLAPI/Modules/Configuration.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22

33
namespace CSharpOpenBMCLAPI.Modules
44
{
5-
public struct Configuration
5+
public readonly struct Configuration
66
{
77
[JsonProperty("sync")]
8-
public Sync Sync { get; set; }
8+
public Sync Sync { get; init; }
99
}
1010

11-
public struct Sync
11+
public readonly struct Sync
1212
{
1313
[JsonProperty("source")]
14-
public string Source { get; set; }
14+
public string Source { get; init; }
1515

1616
[JsonProperty("concurrency")]
17-
public int Concurrency { get; set; }
17+
public int Concurrency { get; init; }
1818
}
1919
}

CSharp-OpenBMCLAPI/Modules/HttpRequest.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
{
33
internal class HttpRequest
44
{
5-
65
public static HttpClient client;
76

8-
97
static HttpRequest()
108
{
119
client = new HttpClient()

CSharp-OpenBMCLAPI/Modules/PublicData.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ public class PublicData(ClusterInfo info)
1010

1111
internal int maxThreadCount;
1212
}
13-
}
13+
}

CSharp-OpenBMCLAPI/Modules/Token.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
/// <summary>
44
/// Token 结构,承载 <seealso cref="Token.token"/> 和 <seealso cref="Token.ttl"/>
55
/// </summary>
6-
public struct Token
6+
public readonly struct Token
77
{
8-
public string token;
9-
public int ttl;
8+
public readonly string token;
9+
public readonly int ttl;
1010
}
1111
}

0 commit comments

Comments
 (0)