コード例 #1
0
ファイル: ImportResult.cs プロジェクト: xzaz/FIRE.X
        public DataTable ImportRulesAsDataTable()
        {
            var dt = new DataTable();

            dt.Locale = CultureInfo.InvariantCulture;

            // add the columns
            foreach (var property in RealType.GetProperties())
            {
                dt.Columns.Add(property.Name, Nullable.GetUnderlyingType(property.PropertyType) ?? property.PropertyType);
            }

            // add the rows
            foreach (var row in ImportRules)
            {
                object[] values = RealType.GetProperties().Select(f => f.GetValue(row)).ToArray();
                dt.Rows.Add(values);
            }

            return(dt);
        }