Skip to content

Commit 883cc37

Browse files
committed
refactor(web): 将 WebData 基类从 IDisposable 改为 IReference
将 WebData 从 IDisposable 模式迁移到引用池模式, 属性改为 protected set 以支持复用,Dispose() 替换为 Clear()。 GameFrameX/com.gameframex.unity#5
1 parent f1326be commit 883cc37

1 file changed

Lines changed: 11 additions & 21 deletions

File tree

Runtime/Web/WebManager.WebData.cs

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using GameFrameX.Runtime;
22

33
namespace GameFrameX.Web.Runtime
44
{
@@ -7,42 +7,32 @@ public partial class WebManager
77
/// <summary>
88
/// Web请求数据的基类,包含请求的基本信息
99
/// </summary>
10-
public class WebData : IDisposable
10+
public class WebData : IReference
1111
{
1212
/// <summary>
1313
/// 获取用户自定义数据
1414
/// </summary>
15-
public object UserData { get; }
15+
public object UserData { get; protected set; }
1616

1717
/// <summary>
1818
/// 获取是否为GET请求
1919
/// </summary>
20-
public bool IsGet { get; }
20+
public bool IsGet { get; protected set; }
2121

2222
/// <summary>
2323
/// 获取请求URL
2424
/// </summary>
25-
public string URL { get; }
25+
public string URL { get; protected set; }
2626

2727
/// <summary>
28-
/// 初始化Web请求数据
28+
/// 重置引用状态,将所有字段恢复为默认值
2929
/// </summary>
30-
/// <param name="isGet">是否为GET请求</param>
31-
/// <param name="url">请求URL</param>
32-
/// <param name="userData">用户自定义数据</param>
33-
protected WebData(bool isGet, string url, object userData = null)
34-
{
35-
UserData = userData;
36-
IsGet = isGet;
37-
URL = url;
38-
}
39-
40-
/// <summary>
41-
/// 释放资源
42-
/// </summary>
43-
public virtual void Dispose()
30+
public virtual void Clear()
4431
{
32+
UserData = default;
33+
IsGet = default;
34+
URL = default;
4535
}
4636
}
4737
}
48-
}
38+
}

0 commit comments

Comments
 (0)