Ejemplo n.º 1
0
        public int Transfer(T source, Addressable destination, long index)
        {
            long initial = index;

            V[] value  = property.GetValue(source);
            int length = value?.Length ?? -1;

            destination.WriteInt32(initial + 4, length);
            index = index + 8;

            if (value != null)
            {
                foreach (V item in value)
                {
                    index = index + nested.Transfer(item, destination.Scope(index));
                }
            }

            destination.WriteInt32(initial, (int)(index - initial));
            return((int)(index - initial));
        }
Ejemplo n.º 2
0
        public override bool TryConvert(ConvertBinder binder, out object result)
        {
            if (binder.Type == typeof(T))
            {
                T destination = Activator.CreateInstance <T>();
                serializer.Transfer(source, destination);

                result = destination;
                return(true);
            }

            return(base.TryConvert(binder, out result));
        }