Skip to content
This repository was archived by the owner on Aug 2, 2020. It is now read-only.

Commit 3e3d07d

Browse files
authored
Merge pull request #79 from Jie2GG/Test
优化修复工具类bug
2 parents 6f5e218 + 7b40bfc commit 3e3d07d

File tree

7 files changed

+775
-740
lines changed

7 files changed

+775
-740
lines changed

Native.Csharp.Sdk/Cqp/CqMsg.cs

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,38 @@ private CqMsg (string message)
4242
Contents = new List<CqCode> ();
4343

4444
// 搜索消息中的 CQ码
45-
MatchCollection matches = _regex[0].Matches (message);
45+
Parse ();
46+
}
47+
#endregion
48+
49+
#region --公开方法--
50+
/// <summary>
51+
/// 将所获取的消息内容序列化为 <see cref="CqMsg"/> 对象
52+
/// </summary>
53+
/// <param name="message"></param>
54+
/// <returns></returns>
55+
public static CqMsg Parse (string message)
56+
{
57+
return new CqMsg (message);
58+
}
59+
#endregion
60+
61+
#region --私有方法--
62+
private void Parse ()
63+
{
64+
MatchCollection matches = _regex[0].Matches (this.OriginalString);
4665
if (matches.Count > 0)
4766
{
4867
foreach (Match match in matches)
4968
{
5069
CqCode tempCode = new CqCode ();
5170

52-
#region --解析 CQ码 类型--
71+
#region --初始化CqCode--
72+
tempCode.OriginalString = match.Groups[0].Value;
73+
tempCode.Index = match.Index;
74+
#endregion
75+
76+
#region --解析CQ码类型--
5377
CqCodeType type = CqCodeType.Unknown;
5478
if (System.Enum.TryParse<CqCodeType> (match.Groups[1].Value, true, out type))
5579
{
@@ -71,17 +95,5 @@ private CqMsg (string message)
7195
}
7296
}
7397
#endregion
74-
75-
#region --公开方法--
76-
/// <summary>
77-
/// 将所获取的消息内容序列化为 <see cref="CqMsg"/> 对象
78-
/// </summary>
79-
/// <param name="message"></param>
80-
/// <returns></returns>
81-
public static CqMsg Parse (string message)
82-
{
83-
return new CqMsg (message);
84-
}
85-
#endregion
8698
}
8799
}

Native.Csharp.Sdk/Cqp/Model/CqCode.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ namespace Native.Csharp.Sdk.Cqp.Model
99
public class CqCode
1010
{
1111
#region --属性--
12+
/// <summary>
13+
/// 获取或设置一个值, 指示当前实例的原始字符串
14+
/// </summary>
15+
public string OriginalString { get; set; }
16+
17+
/// <summary>
18+
/// 获取或设置一个值, 指示当前实例位于消息上下文的起始索引
19+
/// </summary>
20+
public int Index { get; set; }
21+
1222
/// <summary>
1323
/// 获取一个值, 该值指示当前实例所表示的 CQ码 的类型
1424
/// </summary>

Native.Csharp.Sdk/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
3333
//通过使用 "*",如下所示:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("3.0.5.0521")]
36-
[assembly: AssemblyFileVersion("3.0.5.0521")]
35+
[assembly: AssemblyVersion ("3.0.6.0525")]
36+
[assembly: AssemblyFileVersion ("3.0.6.0525")]

0 commit comments

Comments
 (0)