/// <summary>
 /// 通过密钥,对字符串形式的加密数据进行解密
 /// </summary>
 /// <param name="bytes"></param>
 /// <param name="SecretKey">密钥</param>
 /// <param name="SingleLine">True:解析单行;False:解析所有</param>
 /// <param name="Standard">是否使用标准方式</param>
 /// <returns></returns>
 public static string Decrypt(this byte[] bytes, string SecretKey, bool SingleLine = true, bool Standard = false)
 {
     DESCryptoServiceProvider des = new DESCryptoServiceProvider();
     if (Standard)
     {
         des.Mode = CipherMode.ECB;
         des.Padding = PaddingMode.Zeros;
     }
     des.Key = SecretKey.ToMD5().Substring(0, 0x08).ToBytes();
     des.IV = SecretKey.ToMD5().Substring(0, 0x08).ToBytes();
     global::System.IO.MemoryStream ms = new global::System.IO.MemoryStream(bytes);
     string val = string.Empty;
     try
     {
         CryptoStream encStream = new CryptoStream(ms, des.CreateDecryptor(), CryptoStreamMode.Read);
         global::System.IO.StreamReader sr = new global::System.IO.StreamReader(encStream);
         val = SingleLine ? sr.ReadLine() : sr.ReadToEnd();
         sr.Close();
         encStream.Close();
     }
     catch
     {
         val = "密钥错误,解密失败。";
     }
     finally
     {
         ms.Close();
     }
     return val;
 }
        public string SerializeMarshall <T>(T t)
        {
            // if you can, only create one serializer
            // creating serializers is an expensive
            // operation and can be slow
            global::System.Xml.Serialization.XmlSerializer serializer = null;

            serializer = new global::System.Xml.Serialization.XmlSerializer(typeof(T));

            // we will write the our result to memory
            //await using
            global::System.IO.MemoryStream stream = new global::System.IO.MemoryStream();
            // the string will be utf8 encoded
            //await using
            global::System.IO.StreamWriter writer = new global::System.IO.StreamWriter
                                                    (
                stream,
                global::System.Text.Encoding.UTF8
                                                    );

            // here we go!
            serializer.Serialize(writer, t);

            // flush our write to make sure its all there
            writer.Flush();

            // reset the stream back to 0
            stream.Position = 0;

            using global::System.IO.StreamReader reader = new global::System.IO.StreamReader(stream);

            string xml = reader.ReadToEnd();

            return(xml);
        }
        public string SerializeMarshall <T>(T t)
        {
            string result = null;

            using (global::System.IO.MemoryStream ms = new global::System.IO.MemoryStream())
            {
                global::System.Runtime.Serialization.DataContractSerializer serializer = null;
                serializer = new global::System.Runtime.Serialization.DataContractSerializer(typeof(T));

                serializer.WriteObject(ms, t);

                ms.Seek(0, global::System.IO.SeekOrigin.Begin);

                using (global::System.IO.StreamReader sr = new global::System.IO.StreamReader(ms))
                {
                    result = sr.ReadToEnd();
                }
            }

            return(result);
        }