Skip to content

Commit d237356

Browse files
committed
恢复显示基础指令集示例
1 parent a6fe630 commit d237356

File tree

11 files changed

+35
-12
lines changed

11 files changed

+35
-12
lines changed

Quick.Protocol/Base.cs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,20 @@ public class Base
1515
CommandInfos = new QpCommandInfo[]
1616
{
1717
QpCommandInfo.Create(
18-
new Commands.Connect.Request(){ InstructionIds=new[]{ typeof(Base).FullName } },
19-
new Commands.Connect.Response(){ Question=Guid.NewGuid().ToString("N") }),
18+
Commands.Connect.Request.GetDefine(),
19+
Commands.Connect.Response.GetDefine()),
2020
QpCommandInfo.Create(
21-
new Commands.Authenticate.Request(){ Answer=Guid.NewGuid().ToString("N") },
22-
new Commands.Authenticate.Response()),
23-
QpCommandInfo.Create(new Commands.HandShake.Request()),
21+
Commands.Authenticate.Request.GetDefine(),
22+
Commands.Authenticate.Response.GetDefine()),
2423
QpCommandInfo.Create(
25-
new Commands.PrivateCommand.Request(){ Action="Action", Content="Content" },
26-
new Commands.PrivateCommand.Response(){ Content="Content" }),
27-
QpCommandInfo.Create(new Commands.GetQpInstructions.Request())
24+
Commands.HandShake.Request.GetDefine(),
25+
Commands.HandShake.Response.GetDefine()),
26+
QpCommandInfo.Create(
27+
Commands.PrivateCommand.Request.GetDefine(),
28+
Commands.PrivateCommand.Response.GetDefine()),
29+
QpCommandInfo.Create(
30+
Commands.GetQpInstructions.Request.GetDefine(),
31+
Commands.GetQpInstructions.Response.GetDefine())
2832
}
2933
};
3034
}

Quick.Protocol/Commands/Authenticate/Request.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.ComponentModel;
1+
using System;
2+
using System.ComponentModel;
23
using System.Text.Json.Serialization.Metadata;
34

45
namespace Quick.Protocol.Commands.Authenticate
@@ -11,5 +12,7 @@ public class Request : AbstractQpSerializer<Request>, IQpCommandRequest<Request,
1112
/// 认证回答
1213
/// </summary>
1314
public string Answer { get; set; }
15+
16+
public static Request GetDefine() => new Request() { Answer = Guid.NewGuid().ToString("N") };
1417
}
1518
}
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
using System.Text.Json.Serialization.Metadata;
1+
using System;
2+
using System.Text.Json.Serialization.Metadata;
23

34
namespace Quick.Protocol.Commands.Authenticate
45
{
56
public class Response : AbstractQpSerializer<Response>
67
{
78
protected override JsonTypeInfo<Response> GetTypeInfo() => AuthenticateCommandSerializerContext.Default.Response;
8-
9+
public static Response GetDefine() => new Response();
910
}
1011
}

Quick.Protocol/Commands/Connect/Request.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,10 @@ public class Request : AbstractQpSerializer<Request>, IQpCommandRequest<Request,
1414
/// 指令集编号数组
1515
/// </summary>
1616
public string[] InstructionIds { get; set; }
17+
18+
public static Request GetDefine() => new Request()
19+
{
20+
InstructionIds = new[] { typeof(Base).FullName }
21+
};
1722
}
1823
}

Quick.Protocol/Commands/Connect/Response.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Text.Json.Serialization.Metadata;
1+
using System;
2+
using System.Text.Json.Serialization.Metadata;
23

34
namespace Quick.Protocol.Commands.Connect
45
{
@@ -17,5 +18,6 @@ public class Response : AbstractQpSerializer<Response>
1718
/// 认证问题
1819
/// </summary>
1920
public string Question { get; set; }
21+
public static Response GetDefine() => new Response() { Question = Guid.NewGuid().ToString("N") };
2022
}
2123
}

Quick.Protocol/Commands/GetQpInstructions/Request.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ namespace Quick.Protocol.Commands.GetQpInstructions
1010
public class Request : AbstractQpSerializer<Request>, IQpCommandRequest<Request, Response>
1111
{
1212
protected override JsonTypeInfo<Request> GetTypeInfo() => GetQpInstructionsCommandSerializerContext.Default.Request;
13+
public static Request GetDefine() => new Request();
1314
}
1415
}

Quick.Protocol/Commands/GetQpInstructions/Response.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ public class Response: AbstractQpSerializer<Response>
1212
/// 指令集数据
1313
/// </summary>
1414
public QpInstruction[] Data { get; set; }
15+
public static Response GetDefine() => new Response();
1516
}
1617
}

Quick.Protocol/Commands/HandShake/Request.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,7 @@ public class Request : AbstractQpSerializer<Request>, IQpCommandRequest<Request,
2020
/// 启用压缩(默认为false)
2121
/// </summary>
2222
public bool EnableCompress { get; set; } = false;
23+
24+
public static Request GetDefine() => new Request();
2325
}
2426
}

Quick.Protocol/Commands/HandShake/Response.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ namespace Quick.Protocol.Commands.HandShake
55
public class Response : AbstractQpSerializer<Response>
66
{
77
protected override JsonTypeInfo<Response> GetTypeInfo() => HandShakeCommandSerializerContext.Default.Response;
8+
public static Response GetDefine() => new Response();
89
}
910
}

Quick.Protocol/Commands/PrivateCommand/Request.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,7 @@ public class Request : AbstractQpSerializer<Request>, IQpCommandRequest<Request,
1818
/// 内容
1919
/// </summary>
2020
public string Content { get; set; }
21+
22+
public static Request GetDefine() => new Request() { Action = "Action", Content = "Content" };
2123
}
2224
}

0 commit comments

Comments
 (0)