示例#1
0
            protected override int WriteMembers(ByteBuffer buffer, object container)
            {
                int count = 0;

                foreach (object item in (IEnumerable)container)
                {
                    object key   = this.keyAccessor.Get(item);
                    object value = this.valueAccessor.Get(item);
                    if (value != null)
                    {
                        this.keyType.WriteObject(buffer, key);

                        SerializableType effectiveType = this.valueType;
                        if (value.GetType() != effectiveType.type)
                        {
                            effectiveType = this.serializer.GetType(value.GetType());
                        }

                        effectiveType.WriteObject(buffer, value);

                        count += 2;
                    }
                }
                return(count);
            }
示例#2
0
            protected override int WriteMembers(ByteBuffer buffer, object container)
            {
                int count = 0;

                foreach (object item in (IEnumerable)container)
                {
                    if (item == null)
                    {
                        Encoder.WriteObject(buffer, null);
                    }
                    else
                    {
                        SerializableType effectiveType = this.itemType;
                        if (item.GetType() != effectiveType.type)
                        {
                            effectiveType = this.serializer.GetType(item.GetType());
                        }

                        effectiveType.WriteObject(buffer, item);
                    }

                    count++;
                }

                return(count);
            }
示例#3
0
            public override int WriteMembers(ByteBuffer buffer, object container)
            {
                int count = 0;

                if (this.BaseType != null)
                {
                    this.BaseType.WriteMembers(buffer, container);
                }

                foreach (SerialiableMember member in this.Members)
                {
                    object memberValue = member.Accessor.Get(container);
                    if (memberValue != null)
                    {
                        Encoder.WriteSymbol(buffer, (Symbol)memberValue, true);

                        SerializableType effectiveType = member.Type;
                        if (memberValue.GetType() != effectiveType.type)
                        {
                            effectiveType = this.serializer.GetType(memberValue.GetType());
                        }

                        effectiveType.WriteObject(buffer, memberValue);
                        count += 2;
                    }
                }

                return(count);
            }
示例#4
0
            protected override int WriteMemberValue(ByteBuffer buffer, string memberName, object memberValue, SerializableType effectiveType)
            {
                if (memberValue != null)
                {
                    Encoder.WriteString(buffer, memberName, true);
                    effectiveType.WriteObject(buffer, memberValue);
                    return(2);
                }

                return(0);
            }
示例#5
0
 static void WriteObject(AmqpSerializer serializer, ByteBuffer buffer, object graph)
 {
     if (graph == null)
     {
         Encoder.WriteObject(buffer, null);
     }
     else
     {
         SerializableType type = serializer.GetType(graph.GetType());
         type.WriteObject(buffer, graph);
     }
 }
示例#6
0
            protected override int WriteMemberValue(ByteBuffer buffer, string memberName, object memberValue, SerializableType effectiveType)
            {
                if (memberValue == null)
                {
                    Encoder.WriteObject(buffer, null);
                }
                else
                {
                    effectiveType.WriteObject(buffer, memberValue);
                }

                return(1);
            }
示例#7
0
            public override int WriteMembers(ByteBuffer buffer, object container)
            {
                foreach (SerialiableMember member in this.Members)
                {
                    object memberValue = member.Accessor.Get(container);
                    if (memberValue == null)
                    {
                        Encoder.WriteObject(buffer, null);
                    }
                    else
                    {
                        SerializableType effectiveType = member.Type;
                        if (memberValue.GetType() != effectiveType.type)
                        {
                            effectiveType = this.serializer.GetType(memberValue.GetType());
                        }

                        effectiveType.WriteObject(buffer, memberValue);
                    }
                }

                return(this.Members.Length);
            }
            protected override int WriteMemberValue(ByteBuffer buffer, string memberName, object memberValue, SerializableType effectiveType)
            {
                if (memberValue != null)
                {
                    Encoder.WriteString(buffer, memberName, true);
                    effectiveType.WriteObject(buffer, memberValue);
                    return 2;
                }

                return 0;
            }
            protected override int WriteMemberValue(ByteBuffer buffer, string memberName, object memberValue, SerializableType effectiveType)
            {
                if (memberValue == null)
                {
                    Encoder.WriteObject(buffer, null);
                }
                else
                {
                    effectiveType.WriteObject(buffer, memberValue);
                }

                return 1;
            }