Esempio n. 1
0
        void Form1_Load(object sender, EventArgs e)
        {
            //CYFConfigHelper.GetSetting("PluginName");
            //CYFConfigHelper.GetConnectionString("test");
            //Encoding ed = Encoding.UTF8;
            //byte[] sourceByte = ed.GetBytes(txtSource.Text);
            //byte[] keyValue = ed.GetBytes(txtKey.Text);
            //byte[] vecValue = ed.GetBytes(txtvector.Text);
            //byte[] byteResult;
            //Rijndael rij = Rijndael.Create();
            //using (MemoryStream ms = new MemoryStream())
            //{
            //    using (CryptoStream cs = new CryptoStream(ms,rij.CreateEncryptor(keyValue,vecValue),CryptoStreamMode.Write))
            //    {
            //        cs.Write(sourceByte, 0, sourceByte.Length);
            //        cs.FlushFinalBlock();
            //        byteResult = ms.ToArray();
            //        rtbResult.Text = Convert.ToBase64String(byteResult);
            //    }
            //}

            //byte[] tempValue = Convert.FromBase64String(rtbResult.Text.Trim());
            //using (MemoryStream ms = new MemoryStream())
            //{
            //    using (CryptoStream cs = new CryptoStream(ms, rij.CreateDecryptor(keyValue, vecValue), CryptoStreamMode.Write))
            //    {
            //        cs.Write(tempValue, 0, tempValue.Length);
            //        cs.FlushFinalBlock();
            //        rtbResult.Text += "\t\n"+ed.GetString(ms.ToArray());
            //    }
            //}

            //try
            //{
            //    DataTable dt = new DataTable();
            //    DataColumn col = new DataColumn("col1", typeof(string));
            //    dt.Columns.Add(col);
            //    col = new DataColumn("col2", typeof(string));
            //    dt.Columns.Add(col);
            //    col = new DataColumn("col3", typeof(string));
            //    dt.Columns.Add(col);
            //    DataRow dr = dt.NewRow();
            //    dr.ItemArray = new object[] { "1", "回火", "啊啊" };
            //    dt.Rows.Add(dr);
            //    dr = dt.NewRow();
            //    dr.ItemArray = new object[] { "2", "哦噢", "呃呃" };
            //    dt.Rows.Add(dr);
            //    XmlDocument xmldoc = CYFXMLHelper.CreateXmlDoc();
            //    CYFXMLHelper.CreateXmlFromDataTable(xmldoc, dt);
            //    rtbResult.Text = CYFXMLHelper.XmlDocToString(xmldoc, true, true);
            //    DataSet ds = CYFXMLHelper.XmlToDataSet(rtbResult.Text);
            //    if (ds.Tables.Count > 0)
            //        dataGridView1.DataSource = ds.Tables[0];
            //    CYFXMLHelper.DataTableWriteToXml(ds.Tables[0], @"F:\test.xml");
            //}
            //catch (Exception ex)
            //{
            //    throw ex;
            //}
            //CodeFactory codeFactory = new CodeFactory();
            //string code = string.Empty;
            //string result =
            //codeFactory.GetOriginTypeCode("http://localhost:35250/GetName.asmx?wsdl", out code);
            Staf s = new Staf();

            s.Name = "叶晓峰";
            s.Sex  = 1;
            byte[] buff = ByteConvertHelper.ObjectToBytes(s);
            object obj  = ByteConvertHelper.BytesToObject(buff);
            Staf   news = null;

            if (obj is Staf)
            {
                news = obj as Staf;
            }
        }