Ejemplo n.º 1
0
 public override void ToWriter(ReaderWriter Writer)
 {
     Writer.Write(ID);
     Writer.Write(User, true);
     Writer.Write(Private);
     Writer.Write(Source, true);
     Writer.Write(Description, true);
     Writer.Write(Rating);
     Writer.Write(Width);
     Writer.Write(Height);
     Writer.Write(Helper.DateTimeToUnixTime(CreationDate));
     Writer.Write(ViewCount);
     Writer.Write(EditCount);
     Writer.Write(Score);
     Writer.Write(ImageHash, true);
 }
Ejemplo n.º 2
0
 public static BooruPost FromReader(ReaderWriter Reader)
 {
     return(new BooruPost()
     {
         ID = Reader.ReadULong(),
         User = Reader.ReadString(),
         Private = Reader.ReadBool(),
         Source = Reader.ReadString(),
         Description = Reader.ReadString(),
         Rating = Reader.ReadByte(),
         Width = Reader.ReadUInt(),
         Height = Reader.ReadUInt(),
         CreationDate = Helper.UnixTimeToDateTime(Reader.ReadUInt()),
         ViewCount = Reader.ReadULong(),
         EditCount = Reader.ReadULong(),
         Score = Reader.ReadLong(),
         ImageHash = Reader.ReadBytes()
     });
 }
Ejemplo n.º 3
0
        public override void ToWriter(ReaderWriter Writer)
        {
            Writer.Write(MD5Password != null);
            Writer.Write(ID);
            Writer.Write(Username, true);
            if (MD5Password != null)
            {
                Writer.Write(MD5Password, true);
            }

            Writer.Write(IsAdmin);
            Writer.Write(Enabled);
            Writer.Write(CanAddPosts);
            Writer.Write(AdvancePostControl);
            Writer.Write(CanDeletePosts);
            Writer.Write(CanEditPosts);
            Writer.Write(CanEditTags);
            Writer.Write(CanDeleteTags);

            Writer.Write(MaxRating);
        }
Ejemplo n.º 4
0
        public static BooruUser FromReader(ReaderWriter Reader)
        {
            bool includePassword = Reader.ReadBool();

            return(new BooruUser()
            {
                ID = Reader.ReadULong(),
                Username = Reader.ReadString(),
                MD5Password = includePassword ? Reader.ReadString() : null,

                IsAdmin = Reader.ReadBool(),
                Enabled = Reader.ReadBool(),
                CanAddPosts = Reader.ReadBool(),
                AdvancePostControl = Reader.ReadBool(),
                CanDeletePosts = Reader.ReadBool(),
                CanEditPosts = Reader.ReadBool(),
                CanEditTags = Reader.ReadBool(),
                CanDeleteTags = Reader.ReadBool(),

                MaxRating = Reader.ReadUShort()
            });
        }
Ejemplo n.º 5
0
 private static void Request(Stream str, RequestCode RQ, Action <ReaderWriter> ReqCB, Action <ReaderWriter> RespCB)
 {
     using (ReaderWriter rw = new ReaderWriter(str))
     {
         rw.Write((ushort)RQ);
         using (MemoryStream ms = new MemoryStream())
         {
             using (ReaderWriter req_rw = new ReaderWriter(ms))
                 ReqCB(req_rw);
             rw.Write(ms.ToArray(), true);
         }
         rw.Flush();
         if (rw.ReadBool())
         {
             using (MemoryStream ms = new MemoryStream(rw.ReadBytes()))
                 using (ReaderWriter resp_rw = new ReaderWriter(ms))
                     RespCB(resp_rw);
         }
         else
         {
             throw new Exception(rw.ReadString());
         }
     }
 }
Ejemplo n.º 6
0
 public void ToWriter(ReaderWriter Writer)
 {
     Writer.Write((uint)this.Count);
     this.ForEach(x => x.ToWriter(Writer));
 }
Ejemplo n.º 7
0
        /*
         * public void ToWriter(BinaryWriter Writer, Action<float> ProgressCallback)
         * {
         *  Writer.Write(Bytes.Length);
         *  if (ProgressCallback != null)
         *  {
         *      int chunkSize = 1024 * 5;
         *      int chunkCount = Bytes.Length / chunkSize;
         *      for (int i = 0; i < chunkCount; i++)
         *      {
         *          Writer.Write(Bytes, i * chunkSize, chunkSize);
         *          ProgressCallback(i * (float)chunkSize / Bytes.Length);
         *      }
         *      Writer.Write(Bytes, chunkCount * chunkSize, Bytes.Length % chunkSize);
         *      ProgressCallback(1f);
         *  }
         *  else Writer.Write(Bytes);
         * }
         */

        public static BooruImage FromReader(ReaderWriter Reader)
        {
            return(BooruImage.FromBytes(Reader.ReadBytes()));
        }
Ejemplo n.º 8
0
 public override void ToWriter(ReaderWriter Writer)
 {
     Writer.Write(Bytes, true);
 }