@@ -30,10 +30,10 @@ private abstract class FastCall<T>
3030 public virtual void Init ( MethodInfo getMethod , MethodInfo setMethod , CallType type ) { Type = type ; }
3131 public abstract void Read ( T inf , NetDataReader r ) ;
3232 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 ) ;
3737 }
3838
3939 private abstract class FastCallSpecific < TClass , TProperty > : FastCall < TClass >
@@ -45,6 +45,11 @@ private abstract class FastCallSpecific<TClass, TProperty> : FastCall<TClass>
4545 protected Func < TClass , List < TProperty > > GetterList ;
4646 protected Action < TClass , List < TProperty > > SetterList ;
4747
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+
4853 protected TProperty [ ] ReadArrayHelper ( TClass inf , NetDataReader r )
4954 {
5055 ushort count = r . GetUShort ( ) ;
@@ -155,6 +160,33 @@ public FastCallStatic(Action<NetDataWriter, TProperty> write, Func<NetDataReader
155160 public override void Read ( TClass inf , NetDataReader r ) { Setter ( inf , _reader ( r ) ) ; }
156161 public override void Write ( TClass inf , NetDataWriter w ) { _writer ( w , Getter ( inf ) ) ; }
157162
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+
158190 public override void ReadArray ( TClass inf , NetDataReader r )
159191 {
160192 var arr = ReadArrayHelper ( inf , r ) ;
@@ -427,6 +459,10 @@ public EnumByteSerializer(PropertyInfo property, Type propertyType)
427459 }
428460 public override void Read ( T inf , NetDataReader r ) { Property . SetValue ( inf , Enum . ToObject ( PropertyType , r . GetByte ( ) ) , null ) ; }
429461 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>" ) ; }
430466 }
431467
432468 private class EnumIntSerializer < T > : EnumByteSerializer < T >
0 commit comments