Initial Commit
This commit is contained in:
84
MarketData/MarketDataLib/MarketDataModel/Securities.cs
Executable file
84
MarketData/MarketDataLib/MarketDataModel/Securities.cs
Executable file
@@ -0,0 +1,84 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace MarketData.MarketDataModel
|
||||
{
|
||||
class SecurityList : List<Security>
|
||||
{
|
||||
public SecurityList()
|
||||
{
|
||||
}
|
||||
public bool LoadSecurities(String strPathFileName)
|
||||
{
|
||||
StreamReader streamReader = File.OpenText(strPathFileName);
|
||||
String strLine;
|
||||
|
||||
while (null != (strLine = streamReader.ReadLine()))
|
||||
{
|
||||
String symbol;
|
||||
String name;
|
||||
char ch;
|
||||
char leadChar;
|
||||
int index = 0;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (index = 0; index < strLine.Length; index++)
|
||||
{
|
||||
ch = strLine[index];
|
||||
if (ch == ',') break;
|
||||
sb.Append(ch);
|
||||
}
|
||||
index++;
|
||||
symbol = sb.ToString();
|
||||
sb = new StringBuilder();
|
||||
leadChar = ch = strLine[index];
|
||||
if (leadChar == '"')
|
||||
{
|
||||
index++;
|
||||
while (index < strLine.Length && leadChar != (ch = strLine[index]))
|
||||
{
|
||||
sb.Append(ch);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (index < strLine.Length)
|
||||
{
|
||||
ch = strLine[index++];
|
||||
sb.Append(ch);
|
||||
}
|
||||
}
|
||||
name = sb.ToString();
|
||||
Security security = new Security(symbol, name);
|
||||
Add(security);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
class Security
|
||||
{
|
||||
private String symbol;
|
||||
private String name;
|
||||
|
||||
public Security()
|
||||
{
|
||||
}
|
||||
public Security(String symbol, String name)
|
||||
{
|
||||
this.symbol = symbol;
|
||||
this.name = name;
|
||||
}
|
||||
public String Symbol
|
||||
{
|
||||
get { return symbol; }
|
||||
set { symbol = value; }
|
||||
}
|
||||
public String Name
|
||||
{
|
||||
get { return name; }
|
||||
set { name = value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user