Hi Marc, 
I had a similar question about the serialization of objects using protocol 
buffers.
I prefer using a single .proto file for generation of C# and Java file, and 
would like to know if my understanding of how to implement a generic list 
of objects in the .proto file is right or not.

Here is my .proto file:
package test;

option optimize_for = SPEED;

message Dp
{

optional string com = 1;

optional string arga = 2;

optional string dbName = 3;

optional string fName = 4;

optional string dateTime = 5;

optional string inputdataassembly = 6;

optional string inputDataType = 7;

optional string identity = 8;
 enum DataLocation 
{
SERVER = 1;
CLIENT = 2;
ADMIN = 3;
}

optional DataLocation datalocation = 9;

optional Object o = 10;

        // I want this to be of the type List<Object>
message Object
{ 
repeated Object objects = 1;
}

optional string ipaddress = 11;

optional int32 port = 12;

optional string authGuid = 13;

optional string moduleid = 14;

optional bool queued = 15;
}

Thank you.
Regards,
Amina K

On Wednesday, June 20, 2012 9:05:49 AM UTC-4, Marc Gravell wrote:
>
> (note: this is specific to protobuf-net, not "protocol buffers" more 
> widely), but yes: that (a generic list) would work fine, as long as the 
> property has been marked for serialization and given a number. There also 
> doesn't need to be a "set" accessor, although it can make full use of a 
> "set" - i.e. if it finds the list is "null", it will create a new list of 
> the appropriate type and use the "set" to update the object.
>
> So, your code would be fine if it has been designated a number, or a 
> related example:
>
>     [ProtoMember(4)]
>     public List<Order> Orders { get  { return orders; } } 
>     private readonly List<Order> orders = new List<Order>();
>
> Marc
> (protobuf-net)
>
> On 20 June 2012 13:08, Farooq Mushtaq <farooqm...@gmail.com 
> <javascript:>>wrote:
>
>> How can we serialize list of objects by using protobuf-net? Is 
>> protobuf-net support list of objects like 
>> public List(ABC) DEF
>> {
>>        get;
>>        set;
>> }
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Protocol Buffers" group.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msg/protobuf/-/W0yySDcbES8J.
>> To post to this group, send email to prot...@googlegroups.com<javascript:>
>> .
>> To unsubscribe from this group, send email to 
>> protobuf+u...@googlegroups.com <javascript:>.
>> For more options, visit this group at 
>> http://groups.google.com/group/protobuf?hl=en.
>>
>
>
>
> -- 
> Regards, 
>
> Marc
>  

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/protobuf/-/x_xlCL2obnsJ.
To post to this group, send email to protobuf@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to