Skip to content

Commit 23606c6

Browse files
committed
[修改] Command 模块增加 XML 文档注释,完善命令过滤器、中间件、命令包装器和 JsonCommand 功能
1 parent 880627a commit 23606c6

12 files changed

Lines changed: 414 additions & 39 deletions

src/GameFrameX.SuperSocket.Command/AsyncCommandFilter.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,24 @@
33

44
namespace GameFrameX.SuperSocket.Command
55
{
6+
/// <summary>
7+
/// Represents an attribute for filtering asynchronous commands.
8+
/// </summary>
69
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
710
public abstract class AsyncCommandFilterAttribute : CommandFilterBaseAttribute
811
{
912
/// <summary>
10-
/// Called when [command executing].
13+
/// Called before a command is executed asynchronously.
1114
/// </summary>
12-
/// <param name="commandContext"></param>
13-
/// <returns>return if the service should continue to process this session</returns>
15+
/// <param name="commandContext">The context of the command being executed.</param>
16+
/// <returns>A task that represents the asynchronous operation. Returns true if the command should continue execution; otherwise, false.</returns>
1417
public abstract ValueTask<bool> OnCommandExecutingAsync(CommandExecutingContext commandContext);
1518

1619
/// <summary>
17-
/// Called when [command executed].
20+
/// Called after a command is executed asynchronously.
1821
/// </summary>
19-
/// <param name="commandContext">The command context.</param>
22+
/// <param name="commandContext">The context of the command that was executed.</param>
23+
/// <returns>A task that represents the asynchronous operation.</returns>
2024
public abstract ValueTask OnCommandExecutedAsync(CommandExecutingContext commandContext);
2125
}
2226
}

src/GameFrameX.SuperSocket.Command/CommandAttribute.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,43 @@
22

33
namespace GameFrameX.SuperSocket.Command
44
{
5+
/// <summary>
6+
/// Specifies metadata for a command, including its name and key.
7+
/// </summary>
58
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
69
public class CommandAttribute : Attribute
710
{
11+
/// <summary>
12+
/// Gets or sets the name of the command.
13+
/// </summary>
814
public string Name { get; set; }
915

16+
/// <summary>
17+
/// Gets or sets the key associated with the command.
18+
/// </summary>
1019
public object Key { get; set; }
1120

21+
/// <summary>
22+
/// Initializes a new instance of the <see cref="CommandAttribute"/> class.
23+
/// </summary>
1224
public CommandAttribute()
1325
{
1426
}
1527

28+
/// <summary>
29+
/// Initializes a new instance of the <see cref="CommandAttribute"/> class with the specified name.
30+
/// </summary>
31+
/// <param name="name">The name of the command.</param>
1632
public CommandAttribute(string name)
1733
{
1834
Name = name;
1935
}
2036

37+
/// <summary>
38+
/// Initializes a new instance of the <see cref="CommandAttribute"/> class with the specified name and key.
39+
/// </summary>
40+
/// <param name="name">The name of the command.</param>
41+
/// <param name="key">The key associated with the command.</param>
2142
public CommandAttribute(string name, object key)
2243
: this(name)
2344
{

src/GameFrameX.SuperSocket.Command/CommandExecutingContext.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
namespace GameFrameX.SuperSocket.Command
66
{
7+
/// <summary>
8+
/// Represents the context for executing a command.
9+
/// </summary>
710
public struct CommandExecutingContext
811
{
912
/// <summary>
@@ -29,6 +32,9 @@ public struct CommandExecutingContext
2932
/// </value>
3033
public Exception Exception { get; set; }
3134

35+
/// <summary>
36+
/// Gets the cancellation token.
37+
/// </summary>
3238
public CancellationToken CancellationToken { get; set; }
3339
}
34-
}
40+
}

src/GameFrameX.SuperSocket.Command/CommandFilter.cs

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,46 @@
22

33
namespace GameFrameX.SuperSocket.Command
44
{
5+
/// <summary>
6+
/// Defines a filter that can be applied to commands.
7+
/// </summary>
58
public interface ICommandFilter
69
{
10+
/// <summary>
11+
/// Gets the execution order of the filter.
12+
/// </summary>
713
int Order { get; }
814
}
915

16+
/// <summary>
17+
/// Represents a base attribute for command filters.
18+
/// </summary>
1019
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
1120
public abstract class CommandFilterBaseAttribute : Attribute, ICommandFilter
1221
{
1322
/// <summary>
14-
/// Gets or sets the execution order.
23+
/// Gets or sets the execution order of the filter.
1524
/// </summary>
16-
/// <value>
17-
/// The order.
18-
/// </value>
1925
public int Order { get; set; }
2026
}
2127

22-
28+
/// <summary>
29+
/// Represents an attribute for filtering commands.
30+
/// </summary>
2331
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
2432
public abstract class CommandFilterAttribute : CommandFilterBaseAttribute
2533
{
2634
/// <summary>
27-
/// Called when [command executing].
35+
/// Called before a command is executed.
2836
/// </summary>
29-
/// <param name="commandContext">The command context.</param>
37+
/// <param name="commandContext">The context of the command being executed.</param>
38+
/// <returns>True if the command should continue execution; otherwise, false.</returns>
3039
public abstract bool OnCommandExecuting(CommandExecutingContext commandContext);
3140

3241
/// <summary>
33-
/// Called when [command executed].
42+
/// Called after a command is executed.
3443
/// </summary>
35-
/// <param name="commandContext">The command context.</param>
44+
/// <param name="commandContext">The context of the command that was executed.</param>
3645
public abstract void OnCommandExecuted(CommandExecutingContext commandContext);
3746
}
38-
}
47+
}

src/GameFrameX.SuperSocket.Command/CommandMetadata.cs

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

33
namespace GameFrameX.SuperSocket.Command
44
{
5+
/// <summary>
6+
/// Represents metadata for a command, including its name and key.
7+
/// </summary>
58
public class CommandMetadata
69
{
10+
/// <summary>
11+
/// Gets the name of the command.
12+
/// </summary>
713
public string Name { get; private set; }
814

15+
/// <summary>
16+
/// Gets the key associated with the command.
17+
/// </summary>
918
public object Key { get; private set; }
1019

20+
/// <summary>
21+
/// Initializes a new instance of the <see cref="CommandMetadata"/> class with the specified name and key.
22+
/// </summary>
23+
/// <param name="name">The name of the command.</param>
24+
/// <param name="key">The key associated with the command.</param>
1125
public CommandMetadata(string name, object key)
1226
{
1327
Name = name;
1428
Key = key;
1529
}
1630

31+
/// <summary>
32+
/// Initializes a new instance of the <see cref="CommandMetadata"/> class with the specified name.
33+
/// The key is set to the same value as the name.
34+
/// </summary>
35+
/// <param name="name">The name of the command.</param>
1736
public CommandMetadata(string name)
1837
: this(name, name)
1938
{

0 commit comments

Comments
 (0)