コード例 #1
0
        public static void SafeFastCopy <T>(IntPtr source, T[] destination) where T : struct
        {
            ToBytes <T> toBytes = new ToBytes <T>()
            {
                otherArray = destination
            };

            Marshal.Copy(source, toBytes.byteArray, 0, toBytes.byteArray.Length);
        }
コード例 #2
0
        public static void SafeFastCopy <T>(T[] source, IntPtr destination) where T : struct
        {
            ToBytes <T> toBytes = new ToBytes <T>()
            {
                otherArray = source
            };

            Marshal.Copy(toBytes.byteArray, 0, destination, toBytes.byteArray.Length);
        }
コード例 #3
0
 protected static void RegisterPropertyType <T>(
     string typeName, int format, MaxSize <T> maxSize,
     FromBytes <T> fromBytes, ToBytes <T> toBytes
     )
 {
     Converter <T> .Format    = format;
     Converter <T> .TypeName  = typeName;
     Converter <T> .MaxSize   = maxSize;
     Converter <T> .FromBytes = fromBytes;
     Converter <T> .ToBytes   = toBytes;
 }
コード例 #4
0
        private void saveDataFileDialog_FileOk(object sender, CancelEventArgs e)
        {
            string     path       = this.saveDataFileDialog.FileName;
            FileStream fileStream = new FileStream(path, FileMode.Create);

            byte[] serBytes;
            ToBytes <BookDetailList> .GetBytes(ref BookList, out serBytes);

            fileStream.Write(serBytes, 0, serBytes.Length);
            fileStream.Flush();
            fileStream.Close();
            fileStream.Dispose();
        }
コード例 #5
0
        private void SaveConstData(string path)
        {
            FileStream fileStream = new FileStream(path, FileMode.Create);

            byte[]      serBytes;
            BookCosting reff = Cost;

            ToBytes <BookCosting> .GetBytes(ref reff, out serBytes);

            fileStream.Write(serBytes, 0, serBytes.Length);
            fileStream.Flush();
            fileStream.Close();
            fileStream.Dispose();
        }
コード例 #6
0
 private void OnDispaly()
 {
     // 加载用户
     foreach (var client in players.__table.ToList())
     {
         string uac = client.Key;
         string ucl = client.Value.client.name;
         facebook.Add(ucl, uac);
         listBox_Allow.Items.Add(ucl);
     }
     // 准备 Byte[] 数据
     final.Data = books;
     ToBytes <BookInformationList> .GetBytes(ref final, out data);
 }
コード例 #7
0
        /// <summary>
        /// 存储新的用户登录信息
        /// </summary>
        /// <param name="path">文件路径</param>
        private void SaveUsersData(string path)
        {
            FileStream fileStream = new FileStream(path, FileMode.Create);

            byte[] serBytes;
            ToBytes <UserSet> .GetBytes(ref users, out serBytes);

            string longkey = Cipher.getInitVector(24);
            string key     = longkey.Substring(0, 16);
            string iv      = longkey.Substring(16, 8);

            byte[] cipher = Cipher.AESEncrypt(serBytes, key, iv);
            fileStream.Write(cipher, 0, cipher.Length);
            fileStream.Flush();
            fileStream.Close();
            fileStream.Dispose();
            Registry.AddKey2Registry("PublishServer\\Encrypt", "SecretKey", key);
            Registry.AddKey2Registry("PublishServer\\Encrypt", "InitVector", iv);
        }
コード例 #8
0
ファイル: Form_Main.cs プロジェクト: polossk/Publish
        private void tSMI_Sendto_Click(object sender, EventArgs e)
        {
            BookEvaluaionList data = new BookEvaluaionList();

            for (int i = 0, sz = listView_Books.SelectedItems.Count; i < sz; i++)
            {
                string        id  = listView_Books.SelectedItems[i].SubItems[0].Text;
                BookEvaluaion tmp = new BookEvaluaion();
                BookEval.tryFind(int.Parse(id), out tmp);
                data.Add(tmp);
            }
            byte[] raw;
            ToBytes <BookEvaluaionList> .GetBytes(ref data, out raw);

            TcpClientP home = new TcpClientP();

            home.Connect(new IPEndPoint(serverIP, Port.TCP_BOOK_EVALUATION_PORT));
            home.Write(raw);
            home.Close();
            MessageBox.Show("发送成功", "提示", MessageBoxButtons.OK);
        }