Skip to content

Commit be08db1

Browse files
committed
[修改]1. 修改程序集的引用。从改版本开始为手动升级模式
1 parent d20494b commit be08db1

File tree

31 files changed

+187
-194
lines changed

31 files changed

+187
-194
lines changed

GameFrameX.Apps/Account/Login/Entity/LoginState.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using GameFrameX.DataBase.Mongo;
2+
13
namespace GameFrameX.Apps.Account.Login.Entity;
24

35
public class LoginState : CacheState

GameFrameX.Apps/ActorType.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using GameFrameX.Setting;
1+
using GameFrameX.Utility.Setting;
22

33
namespace GameFrameX.Apps;
44

Lines changed: 76 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,113 @@
1-
using GameFrameX.Log;
1+
using GameFrameX.Utility.Log;
22

3-
namespace GameFrameX.Apps
3+
namespace GameFrameX.Apps;
4+
5+
public class DictionaryRepresentationConvention : ConventionBase, IMemberMapConvention
46
{
5-
public class DictionaryRepresentationConvention : ConventionBase, IMemberMapConvention
6-
{
7-
private readonly DictionaryRepresentation _dictionaryRepresentation;
7+
private readonly DictionaryRepresentation _dictionaryRepresentation;
88

9-
public DictionaryRepresentationConvention(DictionaryRepresentation dictionaryRepresentation = DictionaryRepresentation.ArrayOfDocuments)
10-
{
11-
_dictionaryRepresentation = dictionaryRepresentation;
12-
}
9+
public DictionaryRepresentationConvention(DictionaryRepresentation dictionaryRepresentation = DictionaryRepresentation.ArrayOfDocuments)
10+
{
11+
_dictionaryRepresentation = dictionaryRepresentation;
12+
}
1313

14-
public void Apply(BsonMemberMap memberMap)
14+
public void Apply(BsonMemberMap memberMap)
15+
{
16+
var serializer = memberMap.GetSerializer();
17+
if (serializer is IDictionaryRepresentationConfigurable dictionaryRepresentationConfigurable)
1518
{
16-
var serializer = memberMap.GetSerializer();
17-
if (serializer is IDictionaryRepresentationConfigurable dictionaryRepresentationConfigurable)
18-
{
19-
var reconfiguredSerializer = dictionaryRepresentationConfigurable.WithDictionaryRepresentation(_dictionaryRepresentation);
20-
memberMap.SetSerializer(reconfiguredSerializer);
21-
}
19+
var reconfiguredSerializer = dictionaryRepresentationConfigurable.WithDictionaryRepresentation(_dictionaryRepresentation);
20+
memberMap.SetSerializer(reconfiguredSerializer);
2221
}
2322
}
23+
}
2424

25-
public class EmptyContainerSerializeMethodConvention : ConventionBase, IMemberMapConvention
25+
public class EmptyContainerSerializeMethodConvention : ConventionBase, IMemberMapConvention
26+
{
27+
public void Apply(BsonMemberMap memberMap)
2628
{
27-
public void Apply(BsonMemberMap memberMap)
29+
if (memberMap.MemberType.IsGenericType)
2830
{
29-
if (memberMap.MemberType.IsGenericType)
31+
var genType = memberMap.MemberType.GetGenericTypeDefinition();
32+
if (genType == typeof(List<>))
3033
{
31-
var genType = memberMap.MemberType.GetGenericTypeDefinition();
32-
if (genType == typeof(List<>))
34+
memberMap.SetShouldSerializeMethod(o =>
3335
{
34-
memberMap.SetShouldSerializeMethod(o =>
36+
var value = memberMap.Getter(o);
37+
if (value is IList list)
3538
{
36-
var value = memberMap.Getter(o);
37-
if (value is IList list)
38-
{
39-
return list != null && list.Count > 0;
40-
}
39+
return list != null && list.Count > 0;
40+
}
4141

42-
return true;
43-
});
44-
}
42+
return true;
43+
});
44+
}
4545

46-
else if (genType == typeof(ConcurrentDictionary<,>) || genType == typeof(Dictionary<,>))
46+
else if (genType == typeof(ConcurrentDictionary<,>) || genType == typeof(Dictionary<,>))
47+
{
48+
memberMap.SetShouldSerializeMethod(o =>
4749
{
48-
memberMap.SetShouldSerializeMethod(o =>
50+
if (o != null)
4951
{
50-
if (o != null)
52+
var value = memberMap.Getter(o);
53+
if (value != null)
5154
{
52-
var value = memberMap.Getter(o);
53-
if (value != null)
55+
var countProperty = value.GetType().GetProperty("Count");
56+
if (countProperty != null)
5457
{
55-
PropertyInfo countProperty = value.GetType().GetProperty("Count");
56-
if (countProperty != null)
57-
{
58-
int count = (int)countProperty.GetValue(value, null);
59-
return count > 0;
60-
}
58+
var count = (int)countProperty.GetValue(value, null);
59+
return count > 0;
6160
}
6261
}
62+
}
6363

64-
return true;
65-
});
66-
}
64+
return true;
65+
});
6766
}
6867
}
6968
}
69+
}
7070

71-
public static class BsonClassMapHelper
71+
public static class BsonClassMapHelper
72+
{
73+
public static void SetConvention()
7274
{
73-
public static void SetConvention()
74-
{
75-
ConventionRegistry.Register(nameof(DictionaryRepresentationConvention),
76-
new ConventionPack { new DictionaryRepresentationConvention(DictionaryRepresentation.ArrayOfDocuments) }, _ => true);
75+
ConventionRegistry.Register(nameof(DictionaryRepresentationConvention),
76+
new ConventionPack { new DictionaryRepresentationConvention(), }, _ => true);
7777

78-
ConventionRegistry.Register(nameof(EmptyContainerSerializeMethodConvention),
79-
new ConventionPack { new EmptyContainerSerializeMethodConvention() }, _ => true);
80-
}
78+
ConventionRegistry.Register(nameof(EmptyContainerSerializeMethodConvention),
79+
new ConventionPack { new EmptyContainerSerializeMethodConvention(), }, _ => true);
80+
}
8181

82-
/// <summary>
83-
/// 提前注册,简化多态类型处理
84-
/// </summary>
85-
/// <param name="assembly"></param>
86-
public static void RegisterAllClass(System.Reflection.Assembly assembly)
82+
/// <summary>
83+
/// 提前注册,简化多态类型处理
84+
/// </summary>
85+
/// <param name="assembly"></param>
86+
public static void RegisterAllClass(Assembly assembly)
87+
{
88+
var types = assembly.GetTypes();
89+
foreach (var t in types)
8790
{
88-
var types = assembly.GetTypes();
89-
foreach (var t in types)
91+
try
9092
{
91-
try
93+
if (!BsonClassMap.IsClassMapRegistered(t))
9294
{
93-
if (!BsonClassMap.IsClassMapRegistered(t))
94-
{
95-
RegisterClass(t);
96-
}
97-
}
98-
catch (Exception e)
99-
{
100-
LogHelper.Error(e);
95+
RegisterClass(t);
10196
}
10297
}
98+
catch (Exception e)
99+
{
100+
LogHelper.Error(e);
101+
}
103102
}
103+
}
104104

105-
public static void RegisterClass(Type t)
106-
{
107-
var bsonClassMap = new BsonClassMap(t);
108-
bsonClassMap.AutoMap();
109-
bsonClassMap.SetIgnoreExtraElements(true);
110-
bsonClassMap.SetIgnoreExtraElementsIsInherited(true);
111-
BsonClassMap.RegisterClassMap(bsonClassMap);
112-
}
105+
public static void RegisterClass(Type t)
106+
{
107+
var bsonClassMap = new BsonClassMap(t);
108+
bsonClassMap.AutoMap();
109+
bsonClassMap.SetIgnoreExtraElements(true);
110+
bsonClassMap.SetIgnoreExtraElementsIsInherited(true);
111+
BsonClassMap.RegisterClassMap(bsonClassMap);
113112
}
114-
}
113+
}

GameFrameX.Apps/CacheStateTypeManager.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-

2-
3-
using GameFrameX.DataBase.Abstractions;
1+
using GameFrameX.Utility.Extensions;
42

53
namespace GameFrameX.Apps;
64

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
using GameFrameX.Core.Abstractions.Events;
22

3-
namespace GameFrameX.Apps.Common.Event
3+
namespace GameFrameX.Apps.Common.Event;
4+
5+
/// <summary>
6+
/// 表示事件的特性。
7+
/// </summary>
8+
public sealed class EventAttribute : EventInfoAttribute
49
{
510
/// <summary>
6-
/// 表示事件的特性
11+
/// 使用指定的事件ID初始化 <see cref="EventAttribute" /> 类的新实例
712
/// </summary>
8-
public sealed class EventAttribute : EventInfoAttribute
13+
/// <param name="eventId">事件ID。</param>
14+
public EventAttribute(EventId eventId) : base((int)eventId)
915
{
10-
/// <summary>
11-
/// 使用指定的事件ID初始化 <see cref="EventAttribute"/> 类的新实例。
12-
/// </summary>
13-
/// <param name="eventId">事件ID。</param>
14-
public EventAttribute(EventId eventId) : base((int)eventId)
15-
{
16-
}
1716
}
1817
}
Lines changed: 51 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,53 @@
1-
namespace GameFrameX.Apps.Common.Event
1+
namespace GameFrameX.Apps.Common.Event;
2+
3+
public enum EventId
24
{
3-
public enum EventId
4-
{
5-
#region role event
6-
7-
/// <summary>
8-
/// 玩家事件
9-
/// </summary>
10-
SessionRemove = 1000,
11-
12-
/// <summary>
13-
/// 玩家等级提升
14-
/// </summary>
15-
RoleLevelUp = 1001,
16-
17-
/// <summary>
18-
/// 玩家vip改变
19-
/// </summary>
20-
RoleVipChange,
21-
22-
/// <summary>
23-
/// 玩家上线
24-
/// </summary>
25-
OnRoleOnline,
26-
27-
/// <summary>
28-
/// 玩家下线
29-
/// </summary>
30-
OnRoleOffline,
31-
32-
/// <summary>
33-
/// 解锁用
34-
/// </summary>
35-
GotNewPet,
36-
37-
#endregion
38-
39-
/// <summary>
40-
/// 玩家事件分割点
41-
/// </summary>
42-
RoleSeparator = 8000,
43-
44-
#region server event
45-
46-
//服务器事件
47-
/// <summary>
48-
/// 世界等级改变
49-
/// </summary>
50-
WorldLevelChange,
51-
52-
#endregion
53-
}
5+
#region role event
6+
7+
/// <summary>
8+
/// 玩家事件
9+
/// </summary>
10+
SessionRemove = 1000,
11+
12+
/// <summary>
13+
/// 玩家等级提升
14+
/// </summary>
15+
RoleLevelUp = 1001,
16+
17+
/// <summary>
18+
/// 玩家vip改变
19+
/// </summary>
20+
RoleVipChange,
21+
22+
/// <summary>
23+
/// 玩家上线
24+
/// </summary>
25+
OnRoleOnline,
26+
27+
/// <summary>
28+
/// 玩家下线
29+
/// </summary>
30+
OnRoleOffline,
31+
32+
/// <summary>
33+
/// 解锁用
34+
/// </summary>
35+
GotNewPet,
36+
37+
#endregion
38+
39+
/// <summary>
40+
/// 玩家事件分割点
41+
/// </summary>
42+
RoleSeparator = 8000,
43+
44+
#region server event
45+
46+
//服务器事件
47+
/// <summary>
48+
/// 世界等级改变
49+
/// </summary>
50+
WorldLevelChange,
51+
52+
#endregion
5453
}

GameFrameX.Apps/Common/Session/Session.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using GameFrameX.NetWork.Abstractions;
22
using GameFrameX.NetWork.Messages;
3-
using GameFrameX.Setting;
43

54
namespace GameFrameX.Apps.Common.Session;
65

GameFrameX.Apps/Common/Session/SessionManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Threading.Tasks;
33
using GameFrameX.Apps.Common.Event;
44
using GameFrameX.NetWork.Abstractions;
5-
using GameFrameX.Setting;
5+
using GameFrameX.Utility.Setting;
66

77
namespace GameFrameX.Apps.Common.Session;
88

GameFrameX.Apps/GameFrameX.Apps.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</ItemGroup>
1818

1919
<ItemGroup>
20-
<PackageReference Include="GameFrameX.Core" Version="1.2.0-beta16" />
21-
<PackageReference Include="GameFrameX.Monitor" Version="1.2.0-beta16" />
20+
<PackageReference Include="GameFrameX.Core" Version="1.2.0-beta18" />
21+
<PackageReference Include="GameFrameX.Monitor" Version="1.2.0-beta18" />
2222
</ItemGroup>
2323
</Project>

GameFrameX.Apps/GlobalUsings.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,14 @@
55
global using MongoDB.Bson.Serialization.Attributes;
66
global using GameFrameX.Core;
77
global using GameFrameX.Core.Utility;
8-
global using GameFrameX.Core.Components;
98
global using GameFrameX.Core.Events;
109
global using GameFrameX.Core.Hotfix.Agent;
1110
global using GameFrameX.Core.Hotfix;
1211
global using GameFrameX.Core.Actors;
1312
global using GameFrameX.Core.Timer;
14-
global using GameFrameX.Core.Abstractions.Attribute;
1513
global using GameFrameX.Proto.Proto;
1614
global using GameFrameX.DataBase;
17-
global using GameFrameX.DataBase.Mongo;
1815
global using GameFrameX.DataBase.Abstractions;
19-
global using GameFrameX.Extension;
20-
global using GameFrameX.Apps.Common.Event;
2116
global using GameFrameX.Utility;
2217
global using System.Collections;
2318
global using System.Collections.Concurrent;

0 commit comments

Comments
 (0)