Skip to content

Commit a6fe630

Browse files
committed
修复获取指令集信息中示例为空的问题。
1 parent 8db0e67 commit a6fe630

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

Quick.Protocol/Base.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
1-
namespace Quick.Protocol
1+
using System;
2+
3+
namespace Quick.Protocol
24
{
35
public class Base
46
{
5-
public static QpInstruction Instruction => new QpInstruction()
7+
public static QpInstruction Instruction { get; } = new QpInstruction()
68
{
79
Id = typeof(Base).FullName,
810
Name = "基础指令集",
911
NoticeInfos = new QpNoticeInfo[]
1012
{
11-
QpNoticeInfo.Create(new Notices.PrivateNotice())
13+
QpNoticeInfo.Create(new Notices.PrivateNotice(){ Action="Action", Content="Content" })
1214
},
1315
CommandInfos = new QpCommandInfo[]
1416
{
15-
QpCommandInfo.Create(new Commands.Connect.Request()),
16-
QpCommandInfo.Create(new Commands.Authenticate.Request()),
17+
QpCommandInfo.Create(
18+
new Commands.Connect.Request(){ InstructionIds=new[]{ typeof(Base).FullName } },
19+
new Commands.Connect.Response(){ Question=Guid.NewGuid().ToString("N") }),
20+
QpCommandInfo.Create(
21+
new Commands.Authenticate.Request(){ Answer=Guid.NewGuid().ToString("N") },
22+
new Commands.Authenticate.Response()),
1723
QpCommandInfo.Create(new Commands.HandShake.Request()),
18-
QpCommandInfo.Create(new Commands.PrivateCommand.Request()),
24+
QpCommandInfo.Create(
25+
new Commands.PrivateCommand.Request(){ Action="Action", Content="Content" },
26+
new Commands.PrivateCommand.Response(){ Content="Content" }),
1927
QpCommandInfo.Create(new Commands.GetQpInstructions.Request())
2028
}
2129
};

Quick.Protocol/QpInstruction.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
using System.ComponentModel;
1+
using System.Text.Json;
2+
using System.Text.Json.Serialization;
23

34
namespace Quick.Protocol
45
{
6+
[JsonSerializable(typeof(QpInstruction))]
7+
public partial class QpInstructionSerializerContext : JsonSerializerContext { }
8+
59
/// <summary>
610
/// QP指令集
711
/// </summary>
@@ -10,25 +14,24 @@ public class QpInstruction
1014
/// <summary>
1115
/// 指令集编号
1216
/// </summary>
13-
[DisplayName("编号")]
14-
[ReadOnly(true)]
1517
public string Id { get; set; }
1618
/// <summary>
1719
/// 指令集名称
1820
/// </summary>
19-
[DisplayName("名称")]
20-
[ReadOnly(true)]
2121
public string Name { get; set; }
2222
/// <summary>
2323
/// 包含的通知信息数组
2424
/// </summary>
25-
[Browsable(false)]
2625
public QpNoticeInfo[] NoticeInfos { get; set; }
2726
/// <summary>
2827
/// 包含的命令信息数组
2928
/// </summary>
30-
[Browsable(false)]
3129
public QpCommandInfo[] CommandInfos { get; set; }
30+
public QpInstruction Clone()
31+
{
32+
var json = JsonSerializer.Serialize(this, QpInstructionSerializerContext.Default.QpInstruction);
33+
return JsonSerializer.Deserialize(json, QpInstructionSerializerContext.Default.QpInstruction);
34+
}
3235
}
3336
}
3437
/*

0 commit comments

Comments
 (0)