示例#1
0
        public byte[] ToBinary()
        {
            using (var mem = new MemoryStream())
                using (var bin = new BinaryWriter(mem))
                {
                    bin.Write(Signature);
                    bin.Write(Id);
                    bin.Write(PostTypeId);
                    bin.Write(CreationDate.ToBinary());
                    bin.Write(ViewCount);
                    bin.Write(Body ?? "");
                    bin.Write(OwnerUserId);
                    bin.Write(LastEditDate.ToBinary());
                    bin.Write(Title ?? "");
                    bin.Write(AnswerCount);
                    bin.Write(CommentCount);
                    bin.Write(FavoriteCount);
                    bin.Write(Tags == null ? 0 : Tags.Length);
                    if (Tags != null)
                    {
                        foreach (var tag in Tags)
                        {
                            bin.Write(tag);
                        }
                    }

                    return(mem.ToArray());
                }
        }
示例#2
0
        public override void Save(BinaryWriter writer)
        {
            writer.Write(Index);
            writer.Write(Name);
            writer.Write(Level);
            writer.Write((byte)Class);
            writer.Write((byte)Gender);
            writer.Write(Hair);

            writer.Write(CreationDate.ToBinary());

            writer.Write(Deleted);
            writer.Write(DeleteDate.ToBinary());

            writer.Write(HP);
            writer.Write(MP);
            writer.Write(Experience);

            writer.Write(Inventory.Length);
            for (int i = 0; i < Inventory.Length; i++)
            {
                writer.Write(Inventory[i] != null);
                if (Inventory[i] == null)
                {
                    continue;
                }

                Inventory[i].Save(writer);
            }

            writer.Write(Equipment.Length);
            for (int i = 0; i < Equipment.Length; i++)
            {
                writer.Write(Equipment[i] != null);
                if (Equipment[i] == null)
                {
                    continue;
                }

                Equipment[i].Save(writer);
            }

            writer.Write(Magics.Count);
            for (int i = 0; i < Magics.Count; i++)
            {
                Magics[i].Save(writer);
            }

            writer.Write(AutoPot);
            writer.Write(Grade);
            writer.Write(HPItemIndex);
            writer.Write(MPItemIndex);
            writer.Write(AutoHPPercent);
            writer.Write(AutoMPPercent);
            writer.Write(SealCount);
        }
示例#3
0
 public byte[] ToBinary()
 {
     using (var mem = new MemoryStream())
         using (var bin = new BinaryWriter(mem))
         {
             bin.Write(Signature);
             bin.Write(Id);
             bin.Write(PostId);
             bin.Write(UserId);
             bin.Write(CreationDate.ToBinary());
             bin.Write(Text ?? "");
             bin.Write(Score);
             return(mem.ToArray());
         }
 }
示例#4
0
        public override void InternalToBinary(IBinaryRawWriter writer)
        {
            VersionSerializationHelper.EmitVersionByte(writer, VERSION_NUMBER);

            writer.WriteGuid(ID);
            writer.WriteLong(CreationDate.ToBinary());
            writer.WriteLong(LastModifiedDate.ToBinary());

            writer.WriteBoolean(SiteModelExtent != null);
            SiteModelExtent?.ToBinary(writer);

            writer.WriteInt(MachineCount);
            writer.WriteInt(DesignCount);
            writer.WriteInt(SurveyedSurfaceCount);
            writer.WriteInt(AlignmentCount);
        }