コード例 #1
0
        public void fill(TLVList list)
        {
            if (list.getList().Count > 0)
            {
                TLVAmqp element = list.getList()[0];
                if (!element.isNull())
                {
                    _condition = (ErrorCodes)StringEnum.Parse(typeof(ErrorCodes), AMQPUnwrapper <AMQPSymbol> .unwrapSymbol(element).Value);
                }
            }

            if (list.getList().Count > 1)
            {
                TLVAmqp element = list.getList()[1];
                if (!element.isNull())
                {
                    _description = AMQPUnwrapper <AMQPSymbol> .unwrapString(element);
                }
            }

            if (list.getList().Count > 2)
            {
                TLVAmqp element = list.getList()[2];
                if (!element.isNull())
                {
                    _info = AMQPUnwrapper <AMQPSymbol> .unwrapMap(element);
                }
            }
        }
コード例 #2
0
 public void fill(TLVAmqp map)
 {
     if (!map.isNull())
     {
         _annotations = AMQPUnwrapper <Object> .unwrapMap(map);
     }
 }
コード例 #3
0
 public void putElement(TLVAmqp key, TLVAmqp value)
 {
     map[key] = value;
     _size   += key.getLength() + value.getLength();
     _count++;
     update();
 }
コード例 #4
0
 public void fill(TLVAmqp value)
 {
     if (!value.isNull())
     {
         this._value = AMQPUnwrapper <AMQPSymbol> .unwrap(value);
     }
 }
コード例 #5
0
        public static Boolean unwrapBool(TLVAmqp tlv)
        {
            switch (tlv.Code)
            {
            case AMQPType.BOOLEAN:
                byte val = tlv.getValue()[0];
                if (val == 0)
                {
                    return(false);
                }
                else if (val == 1)
                {
                    return(true);
                }
                else
                {
                    throw new MalformedMessageException("Invalid Boolean type value: " + val);
                }

            case AMQPType.BOOLEAN_TRUE:
                return(true);

            case AMQPType.BOOLEAN_FALSE:
                return(false);

            default:
                throw new ArgumentException(new DateTime() + ": " + "Error trying to parse BOOLEAN: received " + tlv.Code);
            }
        }
コード例 #6
0
        public override void fillArguments(TLVList list)
        {
            int size = list.getList().Count;

            if (size == 0)
            {
                throw new MalformedMessageException("Received malformed SASL-Challenge header: challenge can't be null");
            }

            if (size > 1)
            {
                throw new MalformedMessageException("Received malformed SASL-Challenge header. Invalid number of arguments: " + size);
            }

            if (size > 0)
            {
                TLVAmqp element = list.getList()[0];
                if (element.isNull())
                {
                    throw new MalformedMessageException("Received malformed SASL-Challenge header: challenge can't be null");
                }

                _challenge = AMQPUnwrapper <AMQPSymbol> .unwrapBinary(element);
            }
        }
コード例 #7
0
        public static AMQPHeader getAMQP(IByteBuffer buf)
        {
            TLVAmqp list = TLVFactory.getTlv(buf);

            if (list.Code != AMQPType.LIST_0 && list.Code != AMQPType.LIST_8 && list.Code != AMQPType.LIST_32)
            {
                throw new MalformedMessageException("Received amqp-header with malformed arguments");
            }

            AMQPHeader header = null;

            Byte        byteCode = list.Constructor.getDescriptorCode().Value;
            HeaderCodes code     = (HeaderCodes)byteCode;

            switch (code)
            {
            case HeaderCodes.ATTACH:
                header = new AMQPAttach();
                break;

            case HeaderCodes.BEGIN:
                header = new AMQPBegin();
                break;

            case HeaderCodes.CLOSE:
                header = new AMQPClose();
                break;

            case HeaderCodes.DETACH:
                header = new AMQPDetach();
                break;

            case HeaderCodes.DISPOSITION:
                header = new AMQPDisposition();
                break;

            case HeaderCodes.END:
                header = new AMQPEnd();
                break;

            case HeaderCodes.FLOW:
                header = new AMQPFlow();
                break;

            case HeaderCodes.OPEN:
                header = new AMQPOpen();
                break;

            case HeaderCodes.TRANSFER:
                header = new AMQPTransfer();
                break;

            default:
                throw new MalformedMessageException("Received amqp-header with unrecognized performative");
            }

            header.fillArguments((TLVList)list);

            return(header);
        }
コード例 #8
0
        public void fill(TLVList list)
        {
            if (list.getList().Count > 0)
            {
                TLVAmqp element = list.getList()[0];
                if (!element.isNull())
                {
                    _deliveryFailed = AMQPUnwrapper <AMQPSymbol> .unwrapBool(element);
                }
            }

            if (list.getList().Count > 1)
            {
                TLVAmqp element = list.getList()[1];
                if (!element.isNull())
                {
                    _undeliverableHere = AMQPUnwrapper <AMQPSymbol> .unwrapBool(element);
                }
            }

            if (list.getList().Count > 2)
            {
                TLVAmqp element = list.getList()[2];
                if (!element.isNull())
                {
                    _messageAnnotations = AMQPUnwrapper <AMQPSymbol> .unwrapMap(element);
                }
            }
        }
コード例 #9
0
 public void fill(TLVAmqp map)
 {
     if (!map.isNull())
     {
         _properties = AMQPUnwrapper <String> .unwrapMap(map);
     }
 }
コード例 #10
0
        public override void fillArguments(TLVList list)
        {
            int size = list.getList().Count;

            if (size == 0)
            {
                throw new MalformedMessageException("Received malformed SASL-Outcome header: code can't be null");
            }

            if (size > 2)
            {
                throw new MalformedMessageException("Received malformed SASL-Outcome header. Invalid number of arguments: " + size);
            }

            if (size > 0)
            {
                TLVAmqp element = list.getList()[0];
                if (element.isNull())
                {
                    throw new MalformedMessageException("Received malformed SASL-Outcome header: code can't be null");
                }

                _outcomeCode = (OutcomeCodes)AMQPUnwrapper <AMQPSymbol> .unwrapUByte(element);
            }

            if (list.getList().Count > 1)
            {
                TLVAmqp element = list.getList()[1];
                if (!element.isNull())
                {
                    _additionalData = AMQPUnwrapper <AMQPSymbol> .unwrapBinary(element);
                }
            }
        }
コード例 #11
0
 public void setElement(int index, TLVAmqp element)
 {
     _size          -= elements[index].getLength();
     elements[index] = element;
     _size          += element.getLength();
     update();
 }
コード例 #12
0
 public void fill(TLVAmqp list)
 {
     if (!list.isNull())
     {
         _sequence = AMQPUnwrapper <Object> .unwrapList(list);
     }
 }
コード例 #13
0
 public void fill(TLVAmqp value)
 {
     if (!value.isNull())
     {
         _data = AMQPUnwrapper <AMQPSymbol> .unwrapBinary(value);
     }
 }
コード例 #14
0
        public override int getLength()
        {
            int     length    = 8;
            TLVAmqp arguments = this.getArguments();

            length += arguments.getLength();
            return(length);
        }
コード例 #15
0
        public static Double unwrapDouble(TLVAmqp tlv)
        {
            if (tlv.Code != AMQPType.DOUBLE)
            {
                throw new ArgumentException(new DateTime() + ": " + "Error trying to parse DOUBLE: received " + tlv.Code);
            }

            return(BitConverter.ToDouble(tlv.getValue(), 0));
        }
コード例 #16
0
        public static short unwrapShort(TLVAmqp tlv)
        {
            if (tlv.Code != AMQPType.SHORT)
            {
                throw new ArgumentException(new DateTime() + ": " + "Error trying to parse SHORT: received " + tlv.Code);
            }

            return(BitConverter.ToInt16(tlv.getValue(), 0));
        }
コード例 #17
0
        public static float unwrapFloat(TLVAmqp tlv)
        {
            if (tlv.Code != AMQPType.FLOAT)
            {
                throw new ArgumentException(new DateTime() + ": " + "Error trying to parse FLOAT: received " + tlv.Code);
            }

            return(BitConverter.ToSingle(tlv.getValue(), 0));
        }
コード例 #18
0
        public static int unwrapChar(TLVAmqp tlv)
        {
            if (tlv.Code != AMQPType.CHAR)
            {
                throw new ArgumentException(new DateTime() + ": " + "Error trying to parse CHAR: received " + tlv.Code);
            }

            return(BitConverter.ToInt32(tlv.getValue(), 0));
        }
コード例 #19
0
        public static byte unwrapByte(TLVAmqp tlv)
        {
            if (tlv.Code != AMQPType.BYTE)
            {
                throw new ArgumentException(new DateTime() + ": " + "Error trying to parse BYTE: received " + tlv.Code);
            }

            return(tlv.getValue()[0]);
        }
コード例 #20
0
        public static short unwrapUByte(TLVAmqp tlv)
        {
            if (tlv.Code != AMQPType.UBYTE)
            {
                throw new ArgumentException(new DateTime() + ": " + "Error trying to parse UBYTE: received " + tlv.Code);
            }

            return((short)(tlv.getValue()[0] & 0xff));
        }
コード例 #21
0
        public static Guid unwrapUuid(TLVAmqp tlv)
        {
            if (tlv.Code != AMQPType.UUID)
            {
                throw new ArgumentException(
                          new DateTime() + ": " + "Error trying to parse UUID: received " + tlv.Code);
            }

            return(Guid.Parse(Encoding.UTF8.GetString(tlv.getValue())));
        }
コード例 #22
0
        public void addElement(int index, TLVAmqp element)
        {
            int diff = index - elements.Count;

            do
            {
                addElement(new TLVNull());
            }while (diff-- > 0);
            setElement(index, element);
        }
コード例 #23
0
        public TLVAmqp getValue()
        {
            TLVAmqp val = _value != null ? AMQPWrapper <AMQPSymbol> .wrap(_value) : new TLVNull();

            DescribedConstructor constructor = new DescribedConstructor(val.Code, new TLVFixed(AMQPType.SMALL_ULONG, new byte[] { 0x77 }));

            val.Constructor = constructor;

            return(val);
        }
コード例 #24
0
        public static String unwrapString(TLVAmqp tlv)
        {
            AMQPType code = tlv.Code;

            if (code != AMQPType.STRING_8 && code != AMQPType.STRING_32)
            {
                throw new ArgumentException(new DateTime() + ": " + "Error trying to parse STRING: received " + code);
            }
            return(Encoding.UTF8.GetString(tlv.getValue()));
        }
コード例 #25
0
        public static AMQPSection getSection(IByteBuffer buf)
        {
            TLVAmqp value = TLVFactory.getTlv(buf);

            AMQPSection section = null;

            Byte         byteCode = value.Constructor.getDescriptorCode().Value;
            SectionCodes code     = (SectionCodes)byteCode;

            switch (code)
            {
            case SectionCodes.APPLICATION_PROPERTIES:
                section = new ApplicationProperties();
                break;

            case SectionCodes.DATA:
                section = new AMQPData();
                break;

            case SectionCodes.DELIVERY_ANNOTATIONS:
                section = new DeliveryAnnotations();
                break;

            case SectionCodes.FOOTER:
                section = new AMQPFooter();
                break;

            case SectionCodes.HEADER:
                section = new MessageHeader();
                break;

            case SectionCodes.MESSAGE_ANNOTATIONS:
                section = new MessageAnnotations();
                break;

            case SectionCodes.PROPERTIES:
                section = new AMQPProperties();
                break;

            case SectionCodes.SEQUENCE:
                section = new AMQPSequence();
                break;

            case SectionCodes.VALUE:
                section = new AMQPValue();
                break;

            default:
                throw new MalformedMessageException("Received header with unrecognized message section code");
            }

            section.fill(value);

            return(section);
        }
コード例 #26
0
 public override void fillArguments(TLVList list)
 {
     if (list.getList().Count > 0)
     {
         TLVAmqp element = list.getList()[0];
         if (!element.isNull())
         {
             _mechanisms = AMQPUnwrapper <AMQPSymbol> .unwrapArray(element);
         }
     }
 }
コード例 #27
0
        public static AMQPDecimal unwrapDecimal(TLVAmqp tlv)
        {
            AMQPType code = tlv.Code;

            if (code != AMQPType.DECIMAL_32 && code != AMQPType.DECIMAL_64 && code != AMQPType.DECIMAL_128)
            {
                throw new ArgumentException(new DateTime() + ": " + "Error trying to parse DECIMAL: received " + tlv.Code);
            }

            return(new AMQPDecimal(tlv.getValue()));
        }
コード例 #28
0
        public static byte[] unwrapBinary(TLVAmqp tlv)
        {
            AMQPType code = tlv.Code;

            if (code != AMQPType.BINARY_8 && code != AMQPType.BINARY_32)
            {
                throw new ArgumentException(new DateTime() + ": " + "Error trying to parse BINARY: received " + code);
            }

            return(tlv.getValue());
        }
コード例 #29
0
        public static DateTime unwrapTimestamp(TLVAmqp tlv)
        {
            if (tlv.Code != AMQPType.TIMESTAMP)
            {
                throw new ArgumentException(new DateTime() + ": " + "Error trying to parse TIMESTAMP: received " + tlv.Code);
            }

            DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0);

            origin.AddMilliseconds(BitConverter.ToInt64(tlv.getValue(), 0));
            return(origin);
        }
コード例 #30
0
        public void addElement(TLVAmqp element)
        {
            if (_size == 0)
            {
                Constructor.Code = AMQPType.LIST_8;
                _width           = 1;
                _size           += 1;
            }

            elements.Add(element);
            _count++;
            _size += element.getLength();
            update();
        }