Refactor Charter code

This commit is contained in:
2015-11-21 23:10:52 -05:00
parent 5aaed082c9
commit 50304be0c9
7 changed files with 264 additions and 873 deletions
+8 -38
View File
@@ -1,5 +1,5 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
namespace LeafWeb.Web.Charter
@@ -7,22 +7,17 @@ namespace LeafWeb.Web.Charter
[Serializable]
public class PiscalOutput
{
private int nbrCurves; // This is the number of input files that were processed.
private readonly ArrayList curveData; // Each element will be a PiscalCurve element that contains
private readonly List<CurveData> _curveData; // Each element will be a PiscalCurve element that contains
// all of the output data for one curve.
public PiscalOutput()
{
nbrCurves = 0;
curveData = new ArrayList();
_curveData = new List<CurveData>();
}
public bool readFromStream(StreamReader sr, ref String errorMsg)
public bool ReadFromStream(StreamReader sr, ref String errorMsg)
{
CurveData curve;
// Skip the first two lines.
sr.ReadLine();
sr.ReadLine();
var lineNbr = 2;
@@ -34,45 +29,20 @@ namespace LeafWeb.Web.Charter
var more = true;
while (more)
{
curve = new CurveData(sr, ref errorMsg, ref lineNbr);
var curve = new CurveData(sr, ref errorMsg, ref lineNbr);
if (errorMsg.Length > 0)
return false;
curveData.Add(curve);
_curveData.Add(curve);
if (sr.EndOfStream)
more = false;
}
return true;
}
public bool readFromDataFile(Stream fileStream, ref String errorMsg)
public List<CurveData> GetCurveData()
{
StreamReader sr;
if (fileStream == null)
{
errorMsg = "Please choose a data file first";
return false;
}
try
{
sr = new StreamReader(fileStream);
}
catch (Exception openExc)
{
errorMsg = "Error opening file: " + openExc.Message;
return false;
}
readFromStream(sr, ref errorMsg);
sr.Close();
return true;
}
public ArrayList getCurveData()
{
return curveData;
return _curveData;
}
}
}