@@ -88,6 +88,21 @@ private void WriteStringArray(string[] array, Action<string> writer, int count)
88
88
}
89
89
}
90
90
91
+ private void WriteStructPointerArray < T > ( T ? [ ] array , int count ) where T : struct , INdrStructure
92
+ {
93
+ if ( array == null )
94
+ {
95
+ array = new T ? [ 0 ] ;
96
+ }
97
+
98
+ for ( int i = 0 ; i < count ; ++ i )
99
+ {
100
+ INdrStructure value = i < array . Length ? array [ i ] : null ;
101
+ WriteReferent ( value ) ;
102
+ _deferred_writes . Add ( ( ) => WriteStruct ( value ) ) ;
103
+ }
104
+ }
105
+
91
106
private void WriteConformance ( params int [ ] conformance )
92
107
{
93
108
if ( _conformance_position . HasValue )
@@ -857,9 +872,18 @@ public void WriteVaryingStructArray<T>(T[] array, long variance) where T : struc
857
872
858
873
public void WriteVaryingStructPointerArray < T > ( T ? [ ] array , long variance ) where T : struct , INdrStructure
859
874
{
875
+ // Offset.
876
+ WriteInt32 ( 0 ) ;
877
+ // Actual Count
878
+ int var_int = ( int ) variance ;
879
+ if ( var_int < 0 )
880
+ {
881
+ var_int = array . Length ;
882
+ }
883
+ WriteInt32 ( var_int ) ;
860
884
using ( var queue = _deferred_writes . Push ( ) )
861
885
{
862
- WriteVaryingArrayCallback ( array , t => WriteReferent ( t , x => WriteStructInternal ( x ) ) , variance ) ;
886
+ WriteStructPointerArray ( array , ( int ) variance ) ;
863
887
}
864
888
}
865
889
@@ -987,9 +1011,16 @@ public void WriteConformantStructArray<T>(T[] array, long conformance) where T :
987
1011
988
1012
public void WriteConformantStructPointerArray < T > ( T ? [ ] array , long conformance ) where T : struct , INdrStructure
989
1013
{
1014
+ int var_int = ( int ) conformance ;
1015
+ if ( var_int < 0 )
1016
+ {
1017
+ var_int = array ? . Length ?? 0 ;
1018
+ }
1019
+ // Max Count
1020
+ WriteConformance ( var_int ) ;
990
1021
using ( var queue = _deferred_writes . Push ( ) )
991
1022
{
992
- WriteConformantArrayCallback ( array , t => WriteReferent ( t , x => WriteStructInternal ( x ) ) , conformance ) ;
1023
+ WriteStructPointerArray ( array , var_int ) ;
993
1024
}
994
1025
}
995
1026
@@ -1112,9 +1143,26 @@ public void WriteConformantVaryingStructArray<T>(T[] array, long conformance, lo
1112
1143
1113
1144
public void WriteConformantVaryingStructPointerArray < T > ( T ? [ ] array , long conformance , long variance ) where T : struct , INdrStructure
1114
1145
{
1146
+ // Max Count
1147
+ int con_int = ( int ) conformance ;
1148
+ if ( con_int < 0 )
1149
+ {
1150
+ con_int = array . Length ;
1151
+ }
1152
+ WriteConformance ( con_int ) ;
1153
+
1154
+ // Offset.
1155
+ WriteInt32 ( 0 ) ;
1156
+ // Actual Count
1157
+ int var_int = ( int ) variance ;
1158
+ if ( var_int < 0 )
1159
+ {
1160
+ var_int = array . Length ;
1161
+ }
1162
+ WriteInt32 ( var_int ) ;
1115
1163
using ( var queue = _deferred_writes . Push ( ) )
1116
1164
{
1117
- WriteVaryingArrayCallback ( array , t => WriteReferent ( t , x => WriteStructInternal ( x ) ) , variance ) ;
1165
+ WriteStructPointerArray ( array , ( int ) variance ) ;
1118
1166
}
1119
1167
}
1120
1168
0 commit comments