Beispiel #1
0
        static int GetValueSize(Array value, Type type)
        {
            if (value.Length == 0)
            {
                return(0);
            }

            if (type == null)
            {
                type = value.GetValue(0).GetType();
            }

            EncodingBase encoding  = AmqpEncoding.GetEncoding(type);
            int          valueSize = 0;

            foreach (object item in value)
            {
                bool arrayEncoding = true;
                if (encoding.FormatCode == FormatCode.Described && valueSize == 0)
                {
                    arrayEncoding = false;
                }

                valueSize += encoding.GetObjectEncodeSize(item, arrayEncoding);
            }

            return(valueSize);
        }
Beispiel #2
0
        public static int GetObjectEncodeSize(object value)
        {
            if (value == null)
            {
                return(FixedWidth.NullEncoded);
            }

            IAmqpSerializable serializable = value as IAmqpSerializable;

            if (serializable != null)
            {
                return(serializable.EncodeSize);
            }

            EncodingBase encoding = GetEncoding(value);

            return(encoding.GetObjectEncodeSize(value, false));
        }
        private static int GetValueSize(Array value, Type type)
        {
            if (value.Length == 0)
            {
                return(0);
            }
            if (type == null)
            {
                type = value.GetValue(0).GetType();
            }
            EncodingBase encoding         = AmqpEncoding.GetEncoding(type);
            int          objectEncodeSize = 0;

            foreach (object obj in value)
            {
                bool flag = true;
                if (encoding.FormatCode == 0 && objectEncodeSize == 0)
                {
                    flag = false;
                }
                objectEncodeSize = objectEncodeSize + encoding.GetObjectEncodeSize(obj, flag);
            }
            return(objectEncodeSize);
        }