File tree Expand file tree Collapse file tree
Lagrange.Core.NativeAPI/NativeModel/Message/Entity Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,13 +10,13 @@ public struct ReplyEntityStruct
1010 public ReplyEntityStruct ( ) { }
1111
1212 public ulong SrcUid ;
13-
13+
1414 public int SrcSequence ;
15-
15+
1616 public IntPtr Source ;
1717
1818 public int SourceType ;
19-
19+
2020 public static implicit operator ReplyEntityStruct ( ReplyEntity entity )
2121 {
2222 var type = entity . Source switch
@@ -26,15 +26,25 @@ public static implicit operator ReplyEntityStruct(ReplyEntity entity)
2626 BotStranger => 3 ,
2727 _ => 0
2828 } ;
29-
29+
3030 var sourcePtr = type switch
3131 {
32- 1 => Marshal . AllocHGlobal ( Marshal . SizeOf < BotFriend > ( ) ) ,
33- 2 => Marshal . AllocHGlobal ( Marshal . SizeOf < BotGroupMember > ( ) ) ,
34- 3 => Marshal . AllocHGlobal ( Marshal . SizeOf < BotStranger > ( ) ) ,
32+ 1 => Marshal . AllocHGlobal ( Marshal . SizeOf < BotFriendStruct > ( ) ) ,
33+ 2 => Marshal . AllocHGlobal ( Marshal . SizeOf < BotGroupMemberStruct > ( ) ) ,
34+ 3 => Marshal . AllocHGlobal ( Marshal . SizeOf < BotStrangerStruct > ( ) ) ,
3535 _ => IntPtr . Zero
3636 } ;
37-
37+
38+ if ( entity . Source != null && sourcePtr != 0 )
39+ {
40+ switch ( type )
41+ {
42+ case 1 : Marshal . StructureToPtr ( ( BotFriendStruct ) ( BotFriend ) entity . Source , sourcePtr , false ) ; break ;
43+ case 2 : Marshal . StructureToPtr ( ( BotGroupMemberStruct ) ( BotGroupMember ) entity . Source , sourcePtr , false ) ; break ;
44+ case 3 : Marshal . StructureToPtr ( ( BotStrangerStruct ) ( BotStranger ) entity . Source , sourcePtr , false ) ; break ;
45+ }
46+ }
47+
3848 return new ReplyEntityStruct
3949 {
4050 SrcUid = entity . SrcUid ,
You can’t perform that action at this time.
0 commit comments