Beispiel #1
0
    protected override void PrimitiveCollectionSerializeOverride(BoundedStream stream, object boundValue,
                                                                 ValueValueNode childSerializer, SerializedType childSerializedType, FieldLength itemLength, long?itemCount)
    {
        var list = (IList)boundValue;

        // Handle const-sized mismatched collections
        PadList(ref list, itemCount);

        foreach (var value in list)
        {
            if (stream.IsAtLimit)
            {
                break;
            }

            childSerializer.Serialize(stream, value, childSerializedType, itemLength);
        }
    }
Beispiel #2
0
    protected override void PrimitiveCollectionSerializeOverride(BoundedStream stream, object boundValue,
                                                                 ValueValueNode childSerializer, SerializedType childSerializedType, FieldLength itemLength, long?itemCount)
    {
        var array = (Array)BoundValue;

        // Handle const-sized mismatched collections
        PadArray(ref array, itemCount);

        for (var i = 0; i < array.Length; i++)
        {
            if (stream.IsAtLimit)
            {
                break;
            }

            var value = array.GetValue(i);
            childSerializer.Serialize(stream, value, childSerializedType, itemLength);
        }
    }