Exemple #1
0
        public int Transfer(Addressable source, long index, T destination)
        {
            int total  = source.ReadInt32(index + 0);
            int length = source.ReadInt32(index + 4);

            if (length >= 0)
            {
                V[] items = new V[length];
                index = index + 8;

                for (int i = 0; i < length; i++)
                {
                    items[i] = (V)Activator.CreateInstance(typeof(V));
                    index    = index + nested.Transfer(source.Scope(index), items[i]);
                }

                property.SetValue(destination, items);
            }
            else
            {
                property.SetNull(destination);
            }

            return(total);
        }
Exemple #2
0
        public int Transfer(Addressable source, long index, Substitute <T> destination)
        {
            int total = source.ReadInt32(index + 0);

            destination.Add(property.Name, () =>
            {
                int length = source.ReadInt32(index + 4);
                SubstituteArray <V> value = null;

                Substitute <V>[] callback()
                {
                    Substitute <V>[] items = new Substitute <V> [length];
                    index = index + 8;

                    for (int i = 0; i < length; i++)
                    {
                        Addressable scope = source.Scope(index);

                        items[i] = new Substitute <V>(nested, scope);
                        index    = index + nested.Transfer(scope, items[i]);
                    }

                    return(items);
                }

                if (length >= 0)
                {
                    value = new SubstituteArray <V>(length, callback);
                }

                return(value);
            });

            return(total);
        }
Exemple #3
0
        public int Transfer(Addressable source, long index, T destination)
        {
            int length = source.ReadInt32(index + 0);

            property.SetValue(destination, source.ReadString(index + 4, length));
            return(NormalizeLength(length));
        }
Exemple #4
0
        public int Transfer(Addressable source, long index, Substitute <T> destination)
        {
            int length = source.ReadInt32(index + 0);

            destination.Add(property.Name, () =>
            {
                if (length < 0)
                {
                    return(null);
                }

                return(new SubstituteText(length, () => source.ReadString(index + 4, length)));
            });

            return(NormalizeLength(length));
        }