public static List <Target> getList(StockName stockExchng) { using (Stream stream = File.Open(filename, FileMode.Open)) { var bformatter = new BinaryFormatter(); List <Target> allLists = (List <Target>)bformatter.Deserialize(stream); if (stockExchng == StockName.All) { return(allLists); } else { return(allLists.Where(s => s.stockExchange.Value == stockExchng.Value).ToList()); } } }
static public void ReadData(string StockFile, StockName stockName) { List <Target> targetList = getList(StockName.All); System.IO.StreamReader file = new System.IO.StreamReader(Program.root + StockFile); string line; while ((line = file.ReadLine()) != null) { String[] lineSplit = line.Split(','); Target toAdd = new Target(lineSplit[1], lineSplit[0], stockName); if (!targetList.Contains(toAdd)) { targetList.Add(new Target(lineSplit[1], lineSplit[0], stockName)); } } using (Stream stream = File.Open(filename, FileMode.Create)) { var bformatter = new BinaryFormatter(); bformatter.Serialize(stream, targetList); } }
public Target(string shortSymbol, string urlName, StockName istock) { shortIdentifier = shortSymbol; urlIdentifier = urlName; stockExchange = istock; }