Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 2
0
        protected override async Task PrimitiveCollectionSerializeOverrideAsync(BoundedStream stream, object boundValue, ValueValueNode childSerializer,
                                                                                SerializedType childSerializedType, FieldLength itemLength, long?itemCount, CancellationToken cancellationToken)
        {
            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);
                await childSerializer.SerializeAsync(stream, value, childSerializedType, itemLength, cancellationToken)
                .ConfigureAwait(false);
            }
        }
Ejemplo n.º 3
0
 public FieldFloat(int length)
 {
     Length = new FieldLength(length);
 }
Ejemplo n.º 4
0
 /// <summary>
 ///     Initializes a new instance of the MemberSerializedEventArgs class with the member name and value.
 /// </summary>
 /// <param name="memberName">The name of the member.</param>
 /// <param name="value">The value of the member.</param>
 /// <param name="context">The current serialization context.</param>
 /// <param name="offset">The current offset in the stream relative to the start of the overall operation.</param>
 /// <param name="localOffset">The current object-local offset in the stream.</param>
 public MemberSerializedEventArgs(string memberName, object value, BinaryDataSerializationContext context,
                                  FieldLength offset, FieldLength localOffset) : base(memberName, context, offset, localOffset)
 {
     Value = value;
 }
Ejemplo n.º 5
0
    public Task WriteAsync(char value, FieldLength fieldLength, CancellationToken cancellationToken)
    {
        var data = _encoding.GetBytes(new[] { value });

        return(WriteAsync(data, fieldLength, cancellationToken));
    }
 protected abstract Task PrimitiveCollectionSerializeOverrideAsync(BoundedStream stream, object boundValue,
                                                                   ValueValueNode childSerializer, SerializedType childSerializedType, FieldLength itemLength, long?itemCount,
                                                                   CancellationToken cancellationToken);
Ejemplo n.º 7
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);
        }
    }
Ejemplo n.º 8
0
 public IField Configure(string Name, int Size, int Number, FieldLength Length, FieldFormat Format, IFieldFormatter Formatter, IFieldValidator Validator, IFieldParser Parser)
 {
     this.Init(Name, Size, Number, Length, Format, Formatter, Validator, Parser);
     return(this);
 }
Ejemplo n.º 9
0
    public void Write(uint value, FieldLength fieldLength)
    {
        var data = BitConverter.GetBytes(value);

        Write(data, fieldLength);
    }
Ejemplo n.º 10
0
    protected override async Task PrimitiveCollectionSerializeOverrideAsync(BoundedStream stream, object boundValue, ValueValueNode childSerializer,
                                                                            SerializedType childSerializedType, FieldLength itemLength, long?itemCount, CancellationToken cancellationToken)
    {
        var list = (IList)boundValue;

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

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

            await childSerializer.SerializeAsync(stream, value, childSerializedType, itemLength, cancellationToken)
            .ConfigureAwait(false);
        }
    }
Ejemplo n.º 11
0
    public Task WriteAsync(int value, FieldLength fieldLength, CancellationToken cancellationToken)
    {
        var data = BitConverter.GetBytes(value);

        return(WriteAsync(data, fieldLength, cancellationToken));
    }
Ejemplo n.º 12
0
    public Task WriteAsync(sbyte value, FieldLength fieldLength, CancellationToken cancellationToken)
    {
        var data = new[] { (byte)value };

        return(WriteAsync(data, fieldLength, cancellationToken));
    }
Ejemplo n.º 13
0
    public void Write(sbyte value, FieldLength fieldLength)
    {
        var data = new[] { (byte)value };

        Write(data, fieldLength);
    }
Ejemplo n.º 14
0
 public FieldVarbinary(int length)
 {
     Length = new FieldLength(length);
 }
Ejemplo n.º 15
0
 public FieldDecimal(int length, byte decimalDigits)
 {
     Length = new FieldLength(length);
     Length.DecimalDigits = decimalDigits;
 }
Ejemplo n.º 16
0
 private string BuildFieldLength(FieldLength fieldLength)
 => $"{fieldLength.FieldName} {fieldLength.FieldType}" +
 $"({fieldLength.Length}){IsNotNull(fieldLength.IsNotNull)}";
 protected abstract void PrimitiveCollectionSerializeOverride(BoundedStream stream, object boundValue,
                                                              ValueValueNode childSerializer, SerializedType childSerializedType, FieldLength itemLength, long?itemCount);
Ejemplo n.º 18
0
 public IField Configure(string Name, int Size, int Number, FieldLength Length, FieldFormat Format)
 {
     this.Init(Name, Size, Number, Length, Format, FormatHelpers.GetFormatter(Length), ValidatorHelpers.GetValidator(Format), ParserHelpers.GetParser(Length));
     return(this);
 }
Ejemplo n.º 19
0
 /// <summary>
 ///     Initializes a new instance of the MemberSerializingEventArgs class with the member name.
 /// </summary>
 /// <param name="memberName">The name of the member.</param>
 /// <param name="context">The current serialization context.</param>
 /// <param name="offset">The current offset in the stream relative to the start of the overall operation.</param>
 /// <param name="localOffset">The current object-local offset in the stream.</param>
 public MemberSerializingEventArgs(string memberName, BinarySerializationContext context, FieldLength offset, FieldLength localOffset)
 {
     MemberName  = memberName;
     Context     = context;
     Offset      = offset;
     LocalOffset = localOffset;
 }