/// <summary>
        /// Checks that the given POCO type is valid and doesn't contain repeated column names
        /// </summary>
        public static void ValidatePocoType <A>()
        {
            var colNames    = ReportParserUtils.GetColumnNamesFromPocoType <A>();
            var uniqueNames = colNames.ToDictionary(name => name);

            if (colNames.Count() != uniqueNames.Count())
            {
                throw new System.ArgumentException("The given row type contains duplicate column names.");
            }
        }
Example #2
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="reader">Provides the text of the report.</param>
 /// <param name="reportName">An arbitrary name given to this report.</param>
 /// <param name="onError">A callback action that is used when there is
 /// an error in parsing an attribute from the report.</param>
 public AwReport(InputTextReader reader, string reportName,
                 Action <ColumnValuePair, A> onError)
 {
     if (reader == null)
     {
         throw new ArgumentNullException("The input text reader cannot be null.");
     }
     ReportParserUtils.ValidatePocoType <A>();
     this.ReportName = reportName;
     this.reader     = reader;
     this.OnError    = onError;
     ReportParserUtils.GetColumnNamesFromPocoType <A>()
     .ToList().ForEach(name => colNames.Add(name));
 }