예제 #1
0
        private void buttonItem4_Click(object sender, EventArgs e)
        {
            Stream         StreamRead;
            OpenFileDialog DialogueCharger = new OpenFileDialog();

            DialogueCharger.DefaultExt = "shape";
            DialogueCharger.Title      = "Load shape";
            DialogueCharger.Filter     = "frame files (*.shape)|*.shape|All files (*.*)|*.*";
            if (DialogueCharger.ShowDialog() == DialogResult.OK)
            {
                if ((StreamRead = DialogueCharger.OpenFile()) != null)
                {
                    BinaryFormatter BinaryRead           = new BinaryFormatter();
                    Base_Function.BASE_COMMON.Class1 cls = new Base_Function.BASE_COMMON.Class1();
                    cls = (Base_Function.BASE_COMMON.Class1)BinaryRead.Deserialize(StreamRead);
                    StreamRead.Close();
                    if (isChild)
                    {
                        this.phChild.dbList = cls.List;
                    }
                    else
                    {
                        this.ph.dbList = cls.List;
                    }
                    this.ppcPreview.InvalidatePreview();
                }
            }
        }
예제 #2
0
 public bool LoadObj()
 {
     try
     {
         Stream         StreamRead;
         OpenFileDialog DialogueCharger = new OpenFileDialog();
         DialogueCharger.DefaultExt = "sobj";
         DialogueCharger.Title      = "Load sobj";
         DialogueCharger.Filter     = "frame files (*.sobj)|*.sobj|All files (*.*)|*.*";
         if (DialogueCharger.ShowDialog() == DialogResult.OK)
         {
             if ((StreamRead = DialogueCharger.OpenFile()) != null)
             {
                 BinaryFormatter BinaryRead = new BinaryFormatter();
                 ArrayList       a          = (ArrayList)BinaryRead.Deserialize(StreamRead);
                 //this.s = (ArrayList)BinaryRead.Deserialize(StreamRead);
                 this.s.setList(a);
                 StreamRead.Close();
                 this.s.afterLoad();
                 this.redraw(true);
                 return(true);
             }
         }
     }
     catch (Exception e)
     {
         MessageBox.Show("Exception:" + e.ToString(), "Load error:");
     }
     return(false);
 }
        public static int ReadToCountOrEnd(byte[] buffer, int offset, int count, StreamRead streamReadDelegate)
        {
            int num  = 0;
            int num2 = offset;
            int num3 = count;

            while (true)
            {
                int num4 = streamReadDelegate(buffer, num2, num3);
                if (num4 == -1)
                {
                    break;
                }
                num += num4;
                if (num >= count)
                {
                    break;
                }
                if (num4 <= 0)
                {
                    break;
                }
                num2 += num4;
                num3 -= num4;
            }
            return(num);
        }
예제 #4
0
 public void IgnoreBytes(long count)
 {
     var tmp = new StreamRead();
     tmp.Name = currentLabel;
     tmp.Offset = Position;
     tmp.Length = count;
     tmp.Ignore = true;
     reads.Add(tmp);
     ignoredBytes += count;
 }
예제 #5
0
        public void IgnoreBytes(long count)
        {
            var tmp = new StreamRead();

            tmp.Name   = currentLabel;
            tmp.Offset = Position;
            tmp.Length = count;
            tmp.Ignore = true;
            reads.Add(tmp);
            ignoredBytes += count;
        }
예제 #6
0
        public override int Read(byte[] buffer, int offset, int count)
        {
            var tmp = new StreamRead();

            tmp.Name   = currentLabel;
            tmp.Offset = Position;
            tmp.Length = count;
            tmp.Ignore = false;
            reads.Add(tmp);
            readBytes += count;
            return(baseStream.Read(buffer, offset, count));
        }
예제 #7
0
        public void HeadersLenghtIsBiggerThan512()
        {
            var headers = new string('a', 600) + "\r\n\r\n";

            var stream = new MemoryStream();

            stream.Write(Encoding.UTF8.GetBytes(headers));
            stream.Position = 0;
            var reader = new StreamRead(stream);

            Assert.Equal(new string('a', 512), reader.ReadLine());
            Assert.Equal(new string('a', 88), reader.ReadLine());
        }
예제 #8
0
        public void ReadLine()
        {
            var text = "HTTP/1.1 200 OK\r\n" +
                       "Date: Mon, 10 Feb 2020 08:26:32 GMT\r\n" +
                       "Server: Apache\r\n";

            var stream = new MemoryStream();

            stream.Write(Encoding.UTF8.GetBytes(text));
            stream.Position = 0;
            var reader = new StreamRead(stream);

            Assert.Equal("HTTP/1.1 200 OK", reader.ReadLine());
            Assert.Equal("Date: Mon, 10 Feb 2020 08:26:32 GMT", reader.ReadLine());
            Assert.Equal("Server: Apache", reader.ReadLine());
        }
예제 #9
0
        /// <summary>
        /// Releases all resource used by the <see cref="T:FFImageLoading.Work.TaskParameter"/> object.
        /// </summary>
        /// <remarks>Call <see cref="Dispose"/> when you are finished using the
        /// <see cref="T:FFImageLoading.Work.TaskParameter"/>. The <see cref="Dispose"/> method leaves the
        /// <see cref="T:FFImageLoading.Work.TaskParameter"/> in an unusable state. After calling <see cref="Dispose"/>,
        /// you must release all references to the <see cref="T:FFImageLoading.Work.TaskParameter"/> so the garbage
        /// collector can reclaim the memory that the <see cref="T:FFImageLoading.Work.TaskParameter"/> was occupying.</remarks>
        public void Dispose()
        {
            if (!_disposed)
            {
                OnSuccess           = null;
                OnError             = null;
                OnFinish            = null;
                OnDownloadStarted   = null;
                OnDownloadProgress  = null;
                OnFileWriteFinished = null;
                Transformations     = null;
                Stream = null;
                StreamRead.TryDispose();
                StreamRead = null;

                _disposed = true;
            }
        }
예제 #10
0
        public void HeadersLenghtIsBiggerThan512AndReadContent()
        {
            var headers = new string('a', 600) + "\r\n\r\n";
            var content = new string('a', 700);

            var stream = new MemoryStream();

            stream.Write(Encoding.UTF8.GetBytes(headers));
            stream.Write(Encoding.UTF8.GetBytes(content));
            stream.Position = 0;
            var reader = new StreamRead(stream);

            Assert.Equal(new string('a', 512), reader.ReadLine());
            Assert.Equal(new string('a', 88), reader.ReadLine());
            reader.ReadLine();
            Assert.Equal(new string('a', 420), Encoding.UTF8.GetString(reader.ReadBody()));
            Assert.Equal(new string('a', 280), Encoding.UTF8.GetString(reader.ReadBody()));
        }
예제 #11
0
        public void ReadLineAndFinishHeaders()
        {
            var text = "HTTP/1.1 200 OK\r\n" +
                       "Date: Mon, 10 Feb 2020 08:26:32 GMT\r\n" +
                       "\r\n" +
                       "Andrei";

            var stream = new MemoryStream();

            stream.Write(Encoding.UTF8.GetBytes(text));
            stream.Position = 0;
            var reader = new StreamRead(stream);

            Assert.Equal("HTTP/1.1 200 OK", reader.ReadLine());
            Assert.Equal("Date: Mon, 10 Feb 2020 08:26:32 GMT", reader.ReadLine());
            reader.ReadLine();
            Assert.Equal(Encoding.UTF8.GetBytes("Andrei"), reader.ReadBody());
        }
예제 #12
0
		private void StreamReceived(StreamRead obj)
		{
			StreamRead streamRead = obj;

			readStream.Consume(this, null, streamRead.bytes);

			if (readStream.identifierType == NetworkingStream.IdentifierType.Player)
				OnConnected();

			DataRead(null, readStream);

			if (readStream.identifierType == NetworkingStream.IdentifierType.Disconnect)
			{
				OnDisconnected(ObjectMapper.Map<string>(readStream));
				Disconnect();
			}
		}
예제 #13
0
 private void OnStreamRead(StreamReadEventArgs e)
 {
     StreamRead?.Invoke(this, e);
 }
예제 #14
0
		private void StreamReceived(StreamRead streamRead)//object sender, ProgressChangedEventArgs e)
		{
			//StreamRead streamRead = (StreamRead)e.UserState;

			readStream.Consume(this, Players[streamRead.clientIndex], streamRead.bytes);

			DataRead(Players[streamRead.clientIndex], readStream);

			if (ObjectMapper.Compare<string>(readStream, "update"))
				UpdateNewPlayer(Players[streamRead.clientIndex]);

			if (RelayToAll)
				RelayStream(readStream);
		}
예제 #15
0
 public override int Read(byte[] buffer, int offset, int count)
 {
     var tmp = new StreamRead();
     tmp.Name = currentLabel;
     tmp.Offset = Position;
     tmp.Length = count;
     tmp.Ignore = false;
     reads.Add(tmp);
     readBytes += count;
     return baseStream.Read(buffer, offset, count);
 }