亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? objectadapter.cs

?? C# 版本的一個三層商業架構
?? CS
字號:
using System;
using System.Data;
using System.Collections;
using System.ComponentModel;
using System.Reflection;
using CSLA.Resources;

namespace CSLA.Data
{
  /// <summary>
  /// An ObjectAdapter is used to convert data in an object 
  /// or collection into a DataTable.
  /// </summary>
  public class ObjectAdapter
  {
    ArrayList _columns = new ArrayList();
                              
    /// <summary>
    /// Fills the DataSet with data from an object or collection.
    /// </summary>
    /// <remarks>
    /// The name of the DataTable being filled is will be the class name of
    /// the object acting as the data source. The
    /// DataTable will be inserted if it doesn't already exist in the DataSet.
    /// </remarks>
    /// <param name="ds">A reference to the DataSet to be filled.</param>
    /// <param name="source">A reference to the object or collection acting as a data source.</param>
    public void Fill(DataSet ds, object source)
    {
      string className = source.GetType().Name;

      Fill(ds, className, source);
    }

    /// <summary>
    /// Fills the DataSet with data from an object or collection.
    /// </summary>
    /// <remarks>
    /// The name of the DataTable being filled is specified as a parameter. The
    /// DataTable will be inserted if it doesn't already exist in the DataSet.
    /// </remarks>
    /// <param name="ds">A reference to the DataSet to be filled.</param>
    /// <param name="TableName"></param>
    /// <param name="source">A reference to the object or collection acting as a data source.</param>
    public void Fill(DataSet ds, string tableName, object source)
    {
      DataTable dt = ds.Tables[tableName];
      bool exists = (dt != null);

      if(!exists)
        dt = new DataTable(tableName);

      Fill(dt, source);

      if(!exists)
        ds.Tables.Add(dt);
    }

    /// <summary>
    /// Fills a DataTable with data values from an object or collection.
    /// </summary>
    /// <param name="dt">A reference to the DataTable to be filled.</param>
    /// <param name="source">A reference to the object or collection acting as a data source.</param>
    public void Fill(DataTable dt, object source)
    {
      AutoDiscover(source);
      DataCopy(dt, source);
    }

    #region Data Copy

    void DataCopy(DataTable dt, object source)
    {
      if(source == null) return;
      if(_columns.Count < 1) return;

      if(source is IListSource)
      {
        DataCopyIList(dt, ((IListSource)source).GetList());
      }
      else
      {
        if(source is IList)
        {
          DataCopyIList(dt, (IList)source);
        }
        else
        {
          // they gave us a regular object - create a list
          ArrayList col = new ArrayList();
          col.Add(source);
          DataCopyIList(dt, (IList)col);
        }
      }
    }

    void DataCopyIList(DataTable dt, IList ds)
    {
      // create columns if needed
      foreach(string column in _columns)
      {
        if(!dt.Columns.Contains(column))
          dt.Columns.Add(column);
      }

      // load the data into the control
      dt.BeginLoadData();
      for(int index = 0; index < ds.Count; index++)
      {
        DataRow dr = dt.NewRow();
        foreach(string column in _columns)
        {
          try
          {
            dr[column] = GetField(ds[index], column);
          }
          catch(Exception ex)
          {
            dr[column] = ex.Message;
          }
        }
        dt.Rows.Add(dr);
      }
      dt.EndLoadData();
    }

    #endregion

    #region AutoDiscover

    void AutoDiscover(object source)
    {
      object innerSource;

      if(source is IListSource)
      {
        innerSource = ((IListSource)source).GetList();
      }
      else
      {
        innerSource = source;
      }

      _columns.Clear();

      if(innerSource is DataView)
      {
        ScanDataView((DataView)innerSource);
      }
      else
      {
        if(innerSource is IList)
        {
          ScanIList((IList)innerSource);
        }
        else
        {
          // they gave us a regular object
          ScanObject(innerSource);
        }
      }
    }

    void ScanDataView(DataView ds)
    {
      for(int field = 0; field < ds.Table.Columns.Count; field++)
        _columns.Add(ds.Table.Columns[field].ColumnName);
    }

    void ScanIList(IList ds)
    {
      if(ds.Count > 0)
      {
        // retrieve the first item from the list
        object obj = ds[0];

        if(obj is ValueType && obj.GetType().IsPrimitive)
        {
          // the value is a primitive value type
          _columns.Add("Value");
        }
        else
        {
          if(obj is string)
          {
            // the value is a simple string
            _columns.Add("Text");
          }
          else
          {
            // we have a complex Structure or object
            ScanObject(obj);
          }
        }
      }
    }

    void ScanObject(object source)
    {
      Type sourceType = source.GetType();

      // retrieve a list of all public properties
      PropertyInfo [] props = sourceType.GetProperties();
      for(int column = 0; column < props.Length; column++)
        if(props[column].CanRead)
          _columns.Add(props[column].Name);

      // retrieve a list of all public fields
      FieldInfo [] fields = sourceType.GetFields();
      for(int column = 0; column < fields.Length; column++)
        _columns.Add(fields[column].Name);
    }

    #endregion

    #region GetField

    string GetField(object obj, string fieldName)
    {

      if(obj is DataRowView)
      {
        // this is a DataRowView from a DataView
        return ((DataRowView)obj)[fieldName].ToString();
      }
      else
      {
        if(obj is ValueType && obj.GetType().IsPrimitive)
        {
          // this is a primitive value type
          if(obj == null)
            return string.Empty;
          else
            return obj.ToString();
        }
        else
        {
          if(obj is string)
          {
            // this is a simple string
            if(obj == null)
              return string.Empty;
            else
              return obj.ToString();
          }
          else
          {
            // this is an object or Structure
            try
            {
              Type sourcetype = obj.GetType();

              // see if the field is a property
              PropertyInfo prop = sourcetype.GetProperty(fieldName);

              if(prop == null || !prop.CanRead)
              {
                // no readable property of that name exists - check for a field
                FieldInfo field = sourcetype.GetField(fieldName);

                if(field == null)
                {
                  // no field exists either, throw an exception
                  throw new System.Data.DataException(
                    Strings.GetResourceString("NoSuchValueExistsException") + fieldName);
                }
                else
                {
                  // got a field, return its value
                  return field.GetValue(obj).ToString();
                }
              }
              else
              {
                // found a property, return its value
                return prop.GetValue(obj, null).ToString();
              }
            }
            catch(Exception ex)
            {
              throw new System.Data.DataException(
                Strings.GetResourceString("ErrorReadingValueException") + fieldName, ex);
            }
          }
        }
      }
    }

    #endregion

  }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩成人一区二区三区在线观看| 国产成人午夜电影网| 欧美高清一级片在线观看| 日韩欧美国产精品一区| 91精品国产全国免费观看| 欧美日韩精品系列| 欧美精品日日鲁夜夜添| 欧美一区二区三区视频在线 | 亚洲一区二区三区四区五区中文 | 欧美在线视频你懂得| 一本大道久久a久久精品综合| 成人sese在线| 日本韩国一区二区| 欧美日韩国产综合视频在线观看 | 国产精品白丝在线| 自拍偷拍国产精品| 亚洲成在人线免费| 男女男精品视频| 韩国一区二区三区| 成人免费高清在线观看| 色婷婷国产精品| 欧美精品1区2区3区| 欧美成人艳星乳罩| 欧美国产日韩在线观看| 亚洲国产精品一区二区www| 美腿丝袜一区二区三区| 国产精品1024| 欧美午夜免费电影| 久久久国产精华| 亚洲制服丝袜av| 国产91精品入口| 欧美日韩一级片网站| 久久久亚洲高清| 亚洲国产日韩av| 国产一区二区精品久久91| 99国产精品一区| 日韩视频在线永久播放| 中文字幕在线免费不卡| 性做久久久久久久久| 国产精品一区二区在线播放| 一本大道av一区二区在线播放 | 国产精品午夜在线| 亚洲大片精品永久免费| 国产69精品久久99不卡| 欧美高清视频一二三区| 亚洲婷婷国产精品电影人久久| 免费看黄色91| 欧美性大战久久久久久久蜜臀| 久久中文娱乐网| 午夜精品久久久久久久久久久| 国产**成人网毛片九色 | 99麻豆久久久国产精品免费| 欧美一区二区三区四区视频| 亚洲嫩草精品久久| 国产精品综合网| 日韩美女视频一区二区在线观看| 一区二区三区产品免费精品久久75| 极品少妇xxxx精品少妇| 日韩一区二区免费在线电影| 夜夜精品视频一区二区| 成人动漫精品一区二区| 欧美精品一区在线观看| 久久精品国产一区二区三| 欧美老女人在线| 亚洲高清视频在线| 在线亚洲+欧美+日本专区| 中文幕一区二区三区久久蜜桃| 国产在线不卡一区| 亚洲精品一区二区三区四区高清| 视频一区视频二区中文| 欧美日韩免费不卡视频一区二区三区| 亚洲乱码中文字幕| 成人aaaa免费全部观看| 欧美国产激情一区二区三区蜜月| 国产剧情在线观看一区二区| 久久综合九色综合97婷婷| 麻豆国产一区二区| 久久久亚洲午夜电影| 国产成人在线视频免费播放| 久久蜜桃av一区二区天堂| 国产一区二区三区电影在线观看| 精品嫩草影院久久| 丁香五精品蜜臀久久久久99网站| 亚洲国产经典视频| 91农村精品一区二区在线| 综合久久久久综合| 欧美曰成人黄网| 日本伊人色综合网| 精品奇米国产一区二区三区| 国产盗摄女厕一区二区三区| 亚洲欧洲日本在线| 91精品办公室少妇高潮对白| 日韩综合一区二区| 日韩精品在线网站| 波多野结衣欧美| 亚洲午夜在线观看视频在线| 91精品在线麻豆| 国产精品一区二区三区网站| 亚洲欧洲精品天堂一级| 欧美日韩在线免费视频| 久久国产欧美日韩精品| 国产欧美视频一区二区三区| 91麻豆精品一区二区三区| 丝袜美腿亚洲色图| 久久男人中文字幕资源站| 91在线国产福利| 天天操天天干天天综合网| 精品免费国产二区三区| 色先锋资源久久综合| 久久精品国产精品青草| 国产精品伦一区二区三级视频| 欧美亚洲一区二区在线| 黄色成人免费在线| 亚洲一区二区3| 国产亚洲自拍一区| 欧美精品一级二级三级| 国产精品18久久久久久久网站| 一区二区久久久久| 久久久久久麻豆| 欧美精品第一页| 91久久香蕉国产日韩欧美9色| 麻豆国产欧美一区二区三区| 亚洲综合在线电影| 国产亚洲一二三区| 欧美一区二区三区在线视频 | 一区二区三区在线视频观看58| 日韩欧美一区中文| 在线观看视频一区二区| 成人一级黄色片| 久久精品久久精品| 图片区日韩欧美亚洲| 亚洲欧洲精品天堂一级| 国产三级一区二区| 日韩欧美国产一区在线观看| 91官网在线免费观看| 成人黄色av网站在线| 国产高清精品久久久久| 日韩成人午夜电影| 亚洲成人精品一区二区| 一区二区在线看| 亚洲视频在线观看三级| 欧美国产日韩在线观看| 国产午夜一区二区三区| 2023国产精品视频| 欧美成人猛片aaaaaaa| 欧美日韩亚洲高清一区二区| 日本韩国视频一区二区| 欧美性生活影院| 欧美丝袜自拍制服另类| 91精彩视频在线| 欧美性猛交xxxxxxxx| 欧美三级乱人伦电影| 欧美亚洲尤物久久| 欧美日韩一级二级三级| 91精品国产一区二区三区香蕉| 精品视频一区三区九区| 欧美三级中文字幕在线观看| 欧美色视频在线观看| 欧美日韩久久一区二区| 欧美日韩美少妇| 日韩美一区二区三区| 精品福利一二区| 欧美国产国产综合| 一区二区三区不卡视频在线观看 | 精品福利在线导航| 国产亚洲精品aa午夜观看| 中文字幕不卡在线播放| 亚洲欧洲成人自拍| 亚洲自拍偷拍欧美| 麻豆免费精品视频| 国产成人午夜电影网| av电影在线观看一区| 色婷婷综合久久久中文一区二区| 欧美午夜片在线观看| 精品剧情在线观看| 中文字幕国产一区| 亚洲一区二区中文在线| 免费不卡在线观看| caoporn国产一区二区| 欧美亚洲国产一区在线观看网站| 欧美男人的天堂一二区| 久久久91精品国产一区二区精品 | 国产精品水嫩水嫩| 亚洲愉拍自拍另类高清精品| 美女任你摸久久| 成人毛片老司机大片| 欧美人与禽zozo性伦| 国产视频视频一区| 亚洲一区二区欧美| 成人在线视频首页| 欧美久久久久久久久久| 国产欧美视频一区二区| 日韩精品一区第一页| 成人h动漫精品一区二| 6080午夜不卡| 国产欧美一区二区精品性色| 午夜激情一区二区| 91啪在线观看| 国产欧美一区在线| 免费成人在线观看|