Example #1
0
        /// <summary>
        /// Load\\create the cloass from a CSV file.
        /// </summary>
        /// <param name="filePath">The path to the CSV file.</param>
        /// <param name="rowDelimiters">The row\\line delimiters.</param>
        /// <param name="columnDelimiters">The column delimiter\\s</param>
        /// <returns>A CCTDataRows class when successfull, null when not.</returns>
        public static CCTDataRows FromCsvFile(String filePath, String[] rowDelimiters, params String[] columnDelimiters)
        {
            try
            {
                String[] lines = File.ReadAllText(filePath).Split(rowDelimiters, StringSplitOptions.RemoveEmptyEntries);
                if (lines != null && lines.Length > 0)
                {
                    CCTDataRows res = new CCTDataRows();
                    res.rows = new List <CCTRow>();
                    foreach (String s in lines)
                    {
                        if (!String.IsNullOrEmpty(s))
                        {
                            res.rows.Add(CCTRow.FromString(s, columnDelimiters));
                        }
                    }

                    return(res);
                }
            }
            catch (Exception ex)
            {
                ILog.LogError(ex);
            }
            return(null);
        }
Example #2
0
 /// <summary>
 /// Remove the specified item from the items stored in this class.
 /// </summary>
 /// <param name="row"></param>
 public virtual void Remove(CCTRow row)
 {
     if (row != null && rows != null)
     {
         rows.Remove(row);
     }
 }
Example #3
0
 /// <summary>
 /// Add an item.
 /// </summary>
 /// <param name="row">The item to add.</param>
 /// <returns>The row index when successfull, -1 when failed.</returns>
 public virtual int Add(CCTRow row)
 {
     if (row != null)
     {
         if (rows == null)
         {
             rows = new List <CCTRow>();
         }
         row.parent = this;
         rows.Add(row);
         return(rows.Count - 1);
     }
     return(-1);
 }