WriteObject() public abstract method

public abstract WriteObject ( System.ByteBuffer buffer, object graph ) : void
buffer System.ByteBuffer
graph object
return void
Example #1
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)
                    {
                        AmqpCodec.EncodeSymbol(member.Name, buffer);

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

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

                return(count);
            }
Example #2
0
 internal void WriteObjectInternal(ByteBuffer buffer, object graph)
 {
     if (graph == null)
     {
         AmqpEncoding.EncodeNull(buffer);
     }
     else
     {
         SerializableType type = this.GetType(graph.GetType());
         type.WriteObject(buffer, graph);
     }
 }
Example #3
0
 internal void WriteObjectInternal(Stream stream, object graph)
 {
     if (graph == null)
     {
         stream.WriteByte(FormatCode.Null);
     }
     else
     {
         SerializableType type = this.GetType(graph.GetType());
         using (ByteBuffer buffer = new ByteBuffer(1024, true))
         {
             type.WriteObject(buffer, graph);
             stream.Write(buffer.Buffer, buffer.Offset, buffer.Length);
         }
     }
 }
Example #4
0
            public override int WriteMembers(ByteBuffer buffer, object container)
            {
                foreach (SerialiableMember member in this.Members)
                {
                    object memberValue = member.Accessor.Get(container);
                    if (memberValue == null)
                    {
                        AmqpEncoding.EncodeNull(buffer);
                    }
                    else
                    {
                        SerializableType effectiveType = member.Type;
                        if (!effectiveType.Final && memberValue.GetType() != effectiveType.type)
                        {
                            effectiveType = this.serializer.GetType(memberValue.GetType());
                        }

                        effectiveType.WriteObject(buffer, memberValue);
                    }
                }

                return(this.Members.Length);
            }
Example #5
0
            public override int WriteMembers(ByteBuffer buffer, object container)
            {
                int count = 0;

                foreach (object item in (IEnumerable)container)
                {
                    if (item == null)
                    {
                        AmqpEncoding.EncodeNull(buffer);
                    }
                    else
                    {
                        SerializableType effectiveType = this.itemType;
                        if (item.GetType() != effectiveType.type)
                        {
                            effectiveType = this.serializer.GetType(item.GetType());
                        }
                        effectiveType.WriteObject(buffer, item);
                    }
                    ++count;
                }
                return(count);
            }
Example #6
0
            public 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);
            }