Exemple #1
0
        public override void Write(void *fieldAddress, SerializerOutput output)
        {
            var obj = Unsafe.Read <object>(fieldAddress);//obj should not be null here

            var pinnable = Unsafe.As <object, PinnableObject>(ref obj);

            fixed(byte *objectAddress = &pinnable.Pinnable)
            {
                _dataSerializer.Write(objectAddress + _fieldOffset, output);
            }
        }
        public override void Write(void *fieldAddress, SerializerOutput output)
        {
            var array = Unsafe.Read <Array>(fieldAddress);

            if (array == null)
            {
                output.WriteNull();
                return;
            }

            var count = array.Length;


            if (count > 0)
            {
                var sizeTracker = output.BeginSizeTrack();
                {
                    output.EnsureNext(6);
                    output.Write7BitEncodedIntUnchecked(count);
                    output.WriteByteUnchecked((byte)_elementDataType);

                    var pinnable = Unsafe.As <Array, byte[]>(ref array);

                    fixed(byte *address = pinnable)
                    {
                        var tempAddress = address;

                        for (var index = 0; index < count; index++)
                        {
                            _elementSerializer.Write(tempAddress, output);
                            tempAddress += _size;
                        }
                    }
                }
                output.WriteSizeTrack(sizeTracker);
            }
            else
            {
                output.EnsureNext(5);
                output.WriteIntUnchecked(1); //size tracker
                output.WriteByteUnchecked(0);
            }
        }
Exemple #3
0
        public override void Write(void *fieldAddress, SerializerOutput output)
        {
            var value = _get(Unsafe.Read <T>(fieldAddress));

            _dataSerializer.Write(Unsafe.AsPointer(ref value), output);
        }
Exemple #4
0
        public override void Write(void *fieldAddress, SerializerOutput output)
        {
            var address = (byte *)fieldAddress + _fieldOffset;

            _dataSerializer.Write(address, output);
        }
Exemple #5
0
        public void Serialize(T item, SerializerOutput output)
        {
            var childAddress = Unsafe.AsPointer(ref item);

            _methods.Write(childAddress, output);
        }