zoukankan      html  css  js  c++  java
  • XmlDocument序列化到Session

    using System;
    using System.IO;
    using System.Xml;
    using System.Xml.Serialization;
    
    namespace Hxh.API
    {
     /// <summary>
     /// Serializer 的摘要说明。
     /// </summary>
     public class Serializer
     {
      public Serializer()
      {
       //
       // TODO: 在此处添加构造函数逻辑
       //
      }
    
      public static object Serialize(object doc)
      {
       MemoryStream ms=new MemoryStream();
       XmlSerializer xs=new XmlSerializer(typeof(XmlDocument));
       xs.Serialize(ms,doc);
       return ms;
      }
    
      public static object Deserialize(object ms)
      {
       try
       {
        XmlSerializer xs = new XmlSerializer(typeof(XmlDocument));
        MemoryStream msop=(MemoryStream)ms;
        msop.Seek(0,SeekOrigin.Begin);
        return xs.Deserialize(msop);
       }
       catch(Exception ex)
       {
        Console.WriteLine(ex.ToString());
        return null;
    
       }
      }
     }
    }
    
    
  • 相关阅读:
    git中文输入显示问题
    how to write a DLL/SO in C/C++ for Python
    python,ctypes
    vc++,dll,lib文件百科
    c++ singleton
    build python on windows
    web前端后端
    动态链接库*.so的编译与使用
    qt,ui,QUiLoader
    qt,script
  • 原文地址:https://www.cnblogs.com/Leo_wl/p/1725101.html
Copyright © 2011-2022 走看看