Exemple #1
0
        // ReSharper disable once InconsistentNaming
        public void Read(Action <int, Structure> rowHandler)
        {
            var row = 1;

            try
            {
                this.ReadHeaderRow();
                row++;
                while (reader.Peek() >= 0)
                {
                    // Windows excel generates invalid CSV files that contain
                    // \r\n rather than \r as is defined by the spec.
                    if (reader.Peek() == '\n')
                    {
                        reader.Read();
                    }
                    if (reader.Peek() == '%')
                    {
                        SkipLine(); // Skip comment lines
                    }
                    else
                    {
                        rowHandler(row, this.ReadFactRow());
                    }
                    row++;
                }
            }
            catch (InferenceStepsExceededException e)
            {
                Repl.RecordExceptionSourceLocation(e, row);
                throw;
            }
            catch (Exception e)
            {
                var wrapper = new PrologError(e,
                                              string.Format("{0} row {1}",
                                                            Path.GetFileName(Prolog.CurrentSourceFile),
                                                            row));
                Debug.LogException(wrapper);
                Repl.RecordExceptionSourceLocation(e, row);
                throw wrapper;
            }
        }
Exemple #2
0
        // ReSharper disable once InconsistentNaming
        public void Read(Action <int, Structure> rowHandler)
        {
            var row = 1;

            try
            {
                this.ReadHeaderRow();
                row++;
                while (reader.Peek() >= 0)
                {
                    if (reader.Peek() == '%')
                    {
                        SkipLine(); // Skip comment lines
                    }
                    else
                    {
                        rowHandler(row, this.ReadFactRow());
                    }
                    row++;
                }
            }
            catch (InferenceStepsExceededException e)
            {
                Repl.RecordExceptionSourceLocation(e, row);
                throw;
            }
            catch (Exception e)
            {
                var wrapper = new PrologError(e,
                                              string.Format("{0} row {1}",
                                                            Path.GetFileName(Prolog.CurrentSourceFile),
                                                            row));
                UnityEngine.Debug.LogException(wrapper);
                Repl.RecordExceptionSourceLocation(e, row);
                throw wrapper;
            }
        }
Exemple #3
0
 // ReSharper disable once InconsistentNaming
 public void Read(Action<int, Structure> rowHandler)
 {
     var row = 1;
     try
     {
         this.ReadHeaderRow();
         row++;
         while (reader.Peek() >= 0)
         {
     // Windows excel generates invalid CSV files that contain
     // \r\n rather than \r as is defined by the spec.
     if (reader.Peek() == '\n')
         reader.Read();
             if (reader.Peek() == '%')
                 SkipLine(); // Skip comment lines
             else
                 rowHandler(row, this.ReadFactRow());
             row++;
         }
     }
     catch (InferenceStepsExceededException e)
     {
         Repl.RecordExceptionSourceLocation(e, row);
         throw;
     }
     catch (Exception e)
     {
         var wrapper = new PrologError(e,
             string.Format("{0} row {1}",
                           Path.GetFileName(Prolog.CurrentSourceFile),
                           row));
         Debug.LogException(wrapper);
         Repl.RecordExceptionSourceLocation(e, row);
         throw wrapper;
     }
 }