Beispiel #1
0
        public override bool Read(DeserializationContext context, out Object outVal)
        {
            uint numNulls = context.Reader.ReadUInt32();

            // this 'special' object indicates that we haven't read a real object,
            // but should insert a number of NULL values.
            outVal = new ArrayNullValueHolder(numNulls);
            return(true);
        }
Beispiel #2
0
        public bool Read(DeserializationContext context, uint id, uint count, Object type, out Object outVal)
        {
            bool ret = true;

            Array array;

            if (type is BinaryPrimitiveTypeCode)
            {
                // this is a primitive array
                array = ReadPrimitiveTypeArray(context, (BinaryPrimitiveTypeCode)type, (int)count);
            }
            else if (type is Type)
            {
                // this is an object array
                Type convertedType = (Type)type;
                array = Array.CreateInstance(convertedType, (int)count);
                for (int i = 0; i < count; i++)
                {
                    Object val;
                    ret &= ReadValue(context, out val);

                    if (val is DelayedReferenceHolder)
                    {
                        // record this index for fixup
                        DelayedReferenceHolder holder = (DelayedReferenceHolder)val;
                        context.Manager.RecordArrayElementFixup(id, i, holder.ReferenceId);
                    }
                    else if (val is ArrayNullValueHolder)
                    {
                        ArrayNullValueHolder holder = (ArrayNullValueHolder)val;
                        for (int j = 0; j < holder.NumNullValues; j++)
                        {
                            array.SetValue(null, i);
                            i++;
                        }
                    }
                    else
                    {
                        // set this value
                        array.SetValue(val, i);
                    }
                }
            }
            else
            {
                throw new SerializationException("illegal call with:" + type);
            }

            context.Manager.RegisterObject(array, id);
            outVal = array;

            return(ret);
        }
	public override bool Read(DeserializationContext context, out Object outVal)
	{
		uint numNulls = context.Reader.ReadUInt32();

		// this 'special' object indicates that we haven't read a real object,
		// but should insert a number of NULL values.
		outVal = new ArrayNullValueHolder(numNulls);
		return true;
	}