zoukankan      html  css  js  c++  java
  • C# 不是序列化xml 转实体Model【原家独创】

    public static T XmlConvertModel<T>(string xmlStr) where T : class, new()
            {
                T t = new T();
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(xmlStr);
                foreach (XmlNode xnls in xmlDoc.ChildNodes)
                {
                    if (xnls.Name.ToUpper() == typeof(T).Name.ToUpper())
                    {
                        foreach (XmlNode xnl in xnls.ChildNodes)
                        {
                            System.Reflection.PropertyInfo[] propertyInfo = typeof(T).GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
                            foreach (System.Reflection.PropertyInfo pinfo in propertyInfo)
                            {
                                if (xnl.Name.ToUpper() == pinfo.Name.ToUpper())
                                {
                                    pinfo.SetValue(t, xnl.InnerText, null);
                                    break;
                                }
                            }
                        }
                    }
                }
                return t;

            }

  • 相关阅读:
    老罗的OLLYMACHINE
    VGA寄存器一览表
    常用的I/O地址
    使用VESA示例
    打开A20
    Linux 2.2 Framebuffer Device Programming Tutorial
    Linux驱动
    基于Linux核心的汉字显示的尝试
    汉字的动态编码与显示方案
    AT&T语法(一)
  • 原文地址:https://www.cnblogs.com/LuoEast/p/11851984.html
Copyright © 2011-2022 走看看