Ejemplo n.º 1
0
        public void SetColumnNames <T>()
        {
            List <String> names = new List <String>();

            foreach (PropertyInfo property in typeof(T).GetProperties())
            {
                ColumnNameAttribute attr = property.GetCustomAttribute <ColumnNameAttribute>();
                if (attr != null)
                {
                    names.Add(attr.ActualName);
                }
            }

            SetColumnNames(names);
        }
Ejemplo n.º 2
0
        public void AddLine <T>(T item)
        {
            Dictionary <String, String> row = new Dictionary <String, String>();

            foreach (PropertyInfo property in typeof(T).GetProperties())
            {
                ColumnNameAttribute attr = property.GetCustomAttribute <ColumnNameAttribute>();
                if (attr != null)
                {
                    Object thing = property.GetValue(item);
                    if (thing == null)
                    {
                        thing = "";
                    }
                    row.Add(attr.ActualName, thing.ToString());
                }
            }

            AddLine(row);
        }