Home Forums Support Serializing Objects Reply To: Serializing Objects

#482
MarcF
Keymaster

When you say object in object, would something like this be suitable:

[ProtoContract]
public class ClientInfo
{
    [ProtoMember(1)]
    string ClientMessage { get; set; }

    private ClientInfo() { }

    public ClientInfo(string clientMessage)
    {
        this.ClientMessage = clientMessage;
    }
}

[ProtoContract]
public class ServerInfo
{
    [ProtoMember(1)]
    public ClientInfo ClientInfo {get; set;}

    [ProtoMember(2)]
    public string ServerMessage { get; set; }

    private ServerInfo() { }

    public ServerInfo(ClientInfo clientInfo, string serverMessage)
    {
        this.ClientInfo = clientInfo;
        this.ServerMessage = serverMessage;
    }
}