Beispiel #1
0
 protected DescribedType(AmqpContractSerializer serializer, Type type, SerializableType baseType, string descriptorName, ulong?descriptorCode, SerialiableMember[] members, Dictionary <Type, SerializableType> knownTypes, MethodAccessor onDesrialized) : base(serializer, type)
 {
     this.baseType       = (SerializableType.DescribedType)baseType;
     this.descriptorName = descriptorName;
     this.descriptorCode = descriptorCode;
     this.members        = members;
     this.onDeserialized = onDesrialized;
     this.knownTypes     = SerializableType.DescribedType.GetKnownTypes(knownTypes);
 }
Beispiel #2
0
            protected override void Initialize(ByteBuffer buffer, FormatCode formatCode, out int size, out int count, out int encodeWidth, out SerializableType.CollectionType effectiveType)
            {
                object valueOrDefault;

                if (formatCode != 0)
                {
                    throw new AmqpException(AmqpError.InvalidField, SRAmqp.AmqpInvalidFormatCode(formatCode, buffer.Offset));
                }
                effectiveType = null;
                formatCode    = AmqpEncoding.ReadFormatCode(buffer);
                ulong?     nullable   = null;
                AmqpSymbol amqpSymbol = new AmqpSymbol();

                if (formatCode == 68)
                {
                    nullable = new ulong?((ulong)0);
                }
                else if (formatCode == 128 || formatCode == 83)
                {
                    nullable = ULongEncoding.Decode(buffer, formatCode);
                }
                else if (formatCode == 163 || formatCode == 179)
                {
                    amqpSymbol = SymbolEncoding.Decode(buffer, formatCode);
                }
                if (this.AreEqual(this.descriptorCode, this.descriptorName, nullable, amqpSymbol))
                {
                    effectiveType = this;
                }
                else if (this.knownTypes != null)
                {
                    int num = 0;
                    while (num < (int)this.knownTypes.Length)
                    {
                        KeyValuePair <Type, SerializableType> keyValuePair = this.knownTypes[num];
                        if (keyValuePair.Value == null)
                        {
                            SerializableType type = this.serializer.GetType(keyValuePair.Key);
                            keyValuePair = new KeyValuePair <Type, SerializableType>(keyValuePair.Key, type);
                            KeyValuePair <Type, SerializableType> keyValuePair1 = keyValuePair;
                            keyValuePair         = keyValuePair1;
                            this.knownTypes[num] = keyValuePair1;
                        }
                        SerializableType.DescribedType value = (SerializableType.DescribedType)keyValuePair.Value;
                        if (!this.AreEqual(value.descriptorCode, value.descriptorName, nullable, amqpSymbol))
                        {
                            num++;
                        }
                        else
                        {
                            effectiveType = value;
                            break;
                        }
                    }
                }
                if (effectiveType == null)
                {
                    ulong?nullable1 = nullable;
                    if (nullable1.HasValue)
                    {
                        valueOrDefault = nullable1.GetValueOrDefault();
                    }
                    else
                    {
                        valueOrDefault = amqpSymbol.Value;
                    }
                    throw new SerializationException(SRAmqp.AmqpUnknownDescriptor(valueOrDefault, this.type.Name));
                }
                formatCode = AmqpEncoding.ReadFormatCode(buffer);
                if (this.Code != 208)
                {
                    encodeWidth = (formatCode == 193 ? 1 : 4);
                    AmqpEncoding.ReadSizeAndCount(buffer, formatCode, 193, 209, out size, out count);
                    return;
                }
                if (formatCode == 69)
                {
                    int num1 = 0;
                    int num2 = num1;
                    encodeWidth = num1;
                    int num3 = num2;
                    int num4 = num3;
                    count = num3;
                    size  = num4;
                    return;
                }
                encodeWidth = (formatCode == 192 ? 1 : 4);
                AmqpEncoding.ReadSizeAndCount(buffer, formatCode, 192, 208, out size, out count);
            }