using System;
using System.IO;
namespace ProtoBuf
{
///
/// 朋友数据
///
[ProtoContract]
public class FriendData
{
///
/// 数据库流水ID
///
[ProtoMember(1)]
public int DbID;
///
/// 对方的ID
///
[ProtoMember(2)]
public int OtherRoleID;
///
/// 对方的名称
///
[ProtoMember(3)]
public string OtherRoleName;
///
/// 对方的等级
///
[ProtoMember(4)]
public int OtherLevel;
///
/// 对方的职业
///
[ProtoMember(5)]
public int Occupation;
///
/// 对方的在线状态
///
[ProtoMember(6)]
public int OnlineState;
///
/// 所在的地图编号
///
[ProtoMember(7)]
public string Position;
///
/// 朋友数据类型, 0: 好友 1:黑名单 2: 敌人
///
[ProtoMember(8)]
public int FriendType;
}
public class Program
{
public Program ()
{
}
public static void Main (string[] args)
{
try
{
byte[] bytesCmd = null;
FriendData data = new FriendData();
data.DbID = 11111;
MemoryStream ms = new MemoryStream();
Serializer.Serialize(ms, data);
bytesCmd = new byte[ms.Length];
ms.Position = 0;
ms.Read(bytesCmd, 0, bytesCmd.Length);
ms.Dispose();
ms = null;
}
catch (Exception e)
{
System.Diagnostics.Debug.WriteLine(e.Message);
}
}
}
}