@@ -30,10 +30,10 @@ private abstract class FastCall<T>
30
30
public virtual void Init ( MethodInfo getMethod , MethodInfo setMethod , CallType type ) { Type = type ; }
31
31
public abstract void Read ( T inf , NetDataReader r ) ;
32
32
public abstract void Write ( T inf , NetDataWriter w ) ;
33
- public virtual void ReadArray ( T inf , NetDataReader r ) { throw new InvalidTypeException ( "Unsupported type: " + typeof ( T ) + "[]" ) ; }
34
- public virtual void WriteArray ( T inf , NetDataWriter w ) { throw new InvalidTypeException ( "Unsupported type: " + typeof ( T ) + "[]" ) ; }
35
- public virtual void ReadList ( T inf , NetDataReader r ) { throw new InvalidTypeException ( "Unsupported type: List<" + typeof ( T ) + ">" ) ; }
36
- public virtual void WriteList ( T inf , NetDataWriter w ) { throw new InvalidTypeException ( "Unsupported type: List<" + typeof ( T ) + ">" ) ; }
33
+ public abstract void ReadArray ( T inf , NetDataReader r ) ;
34
+ public abstract void WriteArray ( T inf , NetDataWriter w ) ;
35
+ public abstract void ReadList ( T inf , NetDataReader r ) ;
36
+ public abstract void WriteList ( T inf , NetDataWriter w ) ;
37
37
}
38
38
39
39
private abstract class FastCallSpecific < TClass , TProperty > : FastCall < TClass >
@@ -45,6 +45,11 @@ private abstract class FastCallSpecific<TClass, TProperty> : FastCall<TClass>
45
45
protected Func < TClass , List < TProperty > > GetterList ;
46
46
protected Action < TClass , List < TProperty > > SetterList ;
47
47
48
+ public override void ReadArray ( TClass inf , NetDataReader r ) { throw new InvalidTypeException ( "Unsupported type: " + typeof ( TProperty ) + "[]" ) ; }
49
+ public override void WriteArray ( TClass inf , NetDataWriter w ) { throw new InvalidTypeException ( "Unsupported type: " + typeof ( TProperty ) + "[]" ) ; }
50
+ public override void ReadList ( TClass inf , NetDataReader r ) { throw new InvalidTypeException ( "Unsupported type: List<" + typeof ( TProperty ) + ">" ) ; }
51
+ public override void WriteList ( TClass inf , NetDataWriter w ) { throw new InvalidTypeException ( "Unsupported type: List<" + typeof ( TProperty ) + ">" ) ; }
52
+
48
53
protected TProperty [ ] ReadArrayHelper ( TClass inf , NetDataReader r )
49
54
{
50
55
ushort count = r . GetUShort ( ) ;
@@ -155,6 +160,33 @@ public FastCallStatic(Action<NetDataWriter, TProperty> write, Func<NetDataReader
155
160
public override void Read ( TClass inf , NetDataReader r ) { Setter ( inf , _reader ( r ) ) ; }
156
161
public override void Write ( TClass inf , NetDataWriter w ) { _writer ( w , Getter ( inf ) ) ; }
157
162
163
+ public override void ReadList ( TClass inf , NetDataReader r )
164
+ {
165
+ int len ;
166
+ var list = ReadListHelper ( inf , r , out len ) ;
167
+ int listCount = list . Count ;
168
+ if ( len > listCount )
169
+ {
170
+ for ( int i = 0 ; i < listCount ; i ++ )
171
+ list [ i ] = _reader ( r ) ;
172
+ for ( int i = listCount ; i < len ; i ++ )
173
+ list . Add ( _reader ( r ) ) ;
174
+ return ;
175
+ }
176
+ if ( len < listCount )
177
+ list . RemoveRange ( len , listCount - len ) ;
178
+ for ( int i = 0 ; i < len ; i ++ )
179
+ list [ i ] = _reader ( r ) ;
180
+ }
181
+
182
+ public override void WriteList ( TClass inf , NetDataWriter w )
183
+ {
184
+ int len ;
185
+ var list = WriteListHelper ( inf , w , out len ) ;
186
+ for ( int i = 0 ; i < len ; i ++ )
187
+ _writer ( w , list [ i ] ) ;
188
+ }
189
+
158
190
public override void ReadArray ( TClass inf , NetDataReader r )
159
191
{
160
192
var arr = ReadArrayHelper ( inf , r ) ;
@@ -427,6 +459,10 @@ public EnumByteSerializer(PropertyInfo property, Type propertyType)
427
459
}
428
460
public override void Read ( T inf , NetDataReader r ) { Property . SetValue ( inf , Enum . ToObject ( PropertyType , r . GetByte ( ) ) , null ) ; }
429
461
public override void Write ( T inf , NetDataWriter w ) { w . Put ( ( byte ) Property . GetValue ( inf , null ) ) ; }
462
+ public override void ReadArray ( T inf , NetDataReader r ) { throw new InvalidTypeException ( "Unsupported type: Enum[]" ) ; }
463
+ public override void WriteArray ( T inf , NetDataWriter w ) { throw new InvalidTypeException ( "Unsupported type: Enum[]" ) ; }
464
+ public override void ReadList ( T inf , NetDataReader r ) { throw new InvalidTypeException ( "Unsupported type: List<Enum>" ) ; }
465
+ public override void WriteList ( T inf , NetDataWriter w ) { throw new InvalidTypeException ( "Unsupported type: List<Enum>" ) ; }
430
466
}
431
467
432
468
private class EnumIntSerializer < T > : EnumByteSerializer < T >
0 commit comments