Common/ReflectHelper.cs

(开头部分) 11KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

/**********************************************
 * 类作用:   反射辅助类
 * 建立人:   abaal
 * 建立时间: 2008-09-03 
 * Copyright (C) 2007-2008 abaal
 * All rights reserved
 * http://blog.csdn.net/abaal888
 ***********************************************/
using System;
using System.Reflection;
using System.Data;
using System.Drawing;
using System.Resources;
using System.ComponentModel;
using System.Text;
using System.IO;

namespace Svnhost.Common
{
    /// <summary>
    /// 反射辅助类
    /// </summary>
    /// <remarks>
    /// 作 者: abaal
    /// 日 期: 2008-09-03
    /// </remarks>
    public static class ReflectHelper
    {
        #region 成员读写
        /// <summary>
        /// 通过数据行填充实体类型
        /// </summary>
        /// <param name="model">实体对象</param>
        /// <param name="dRow">数据行</param>
        public static void FillInstanceValue(object model, DataRow dRow)
        {
            Type type = model.GetType();
            for (int i = 0; i < dRow.Table.Columns.Count; i++)
            {
                PropertyInfo property = type.GetProperty(dRow.Table.Columns[i].ColumnName);
                if (property != null)
                {
                    property.SetValue(model, dRow[i], null);
                }
            }
        }

        /// <summary>
        /// 通过数据只读器填充实体类型
        /// </summary>
        /// <param name="model">实体对象</param>
        /// <param name="dr">数据只读器</param>
        public static void FillInstanceValue(object model, IDataReader dr)
        {
            Type type = model.GetType();
            for (int i = 0; i < dr.FieldCount; i++)
            {
                PropertyInfo property = type.GetProperty(dr.GetName(i));
                if (property != null)
                {
后面还有 210 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。