本文整理汇总了C#中Converter.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Converter.ToString方法的具体用法?C# Converter.ToString怎么用?C# Converter.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Converter
的用法示例。
在下文中一共展示了Converter.ToString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: convert
bool convert(Converter con, string filename,int tradesize,string sym)
{
int bads = 0;
int thistotal = _ticksprocessed;
bool g = true;
// get output filename
string convertname = string.Empty;
// setup writing to output
TikWriter outfile = null;
// setup input file
StreamReader infile = null;
int _date = 0;
int cqgdecimalplaces = 2;
try
{
// open input file
switch (con)
{
case Converter.TradeStation:
infile = new StreamReader(filename);
// read in and ignore header of input file
infile.ReadLine();
break;
case Converter.eSignal_EPF:
infile = new StreamReader(filename);
// ignore header
SecurityImpl esec = eSigTick.InitEpf(infile);
_sym = esec.Symbol;
break;
case Converter.CQG:
infile = new StreamReader(filename);
cqgdecimalplaces = (int) this._cqgdecimalplacesinput.Value;
// no header
break;
case Converter.TradingPhysicsTnS:
case Converter.TradingPhysicsTV:
string file = System.IO.Path.GetFileName(filename);
string[] date_sym = file.Split('_');
string[] sym_ext = date_sym[1].Split('.');
string datestr = date_sym[0];
int.TryParse(datestr, out _date);
_sym = sym_ext[0];
infile = new StreamReader(filename);
infile.ReadLine();//discard header line
break;
case Converter.QCollector_eSignal:
infile = new StreamReader(filename);
// no header in file
break;
case Converter.MultiCharts:
// The symbol for data being imported is obtained from the filename
// Selected files for import must be named SYMBOL.ext - eg AAPL.txt, GOOG.txt
_sym = System.IO.Path.GetFileNameWithoutExtension(filename);
infile = new StreamReader(filename);
infile.ReadLine(); // ignore first line header of input file
break;
}
}
catch (Exception ex) { debug("error reading input header:" + ex.Message); g = false; }
// setup previous tick and current tick
Tick pk = new TickImpl();
Tick k = null;
do
{
try
{
// get next tick from the file
switch (con)
{
case Converter.CQG:
k = CQG.parseline(infile.ReadLine(), tradesize, cqgdecimalplaces );
break;
case Converter.eSignal_EPF:
k = eSigTick.FromStream(_sym, infile);
break;
case Converter.TradeStation:
k = TradeStation.parseline(infile.ReadLine(), sym, tradesize);
break;
case Converter.TradingPhysicsTnS:
k = TradingPhysicsTnS.parseline(infile.ReadLine(), _sym, _date);
break;
case Converter.TradingPhysicsTV:
k = TradingPhysicsTV.parseline(infile.ReadLine(), _sym, _date);
break;
case Converter.QCollector_eSignal:
k = QCollector.parseline(infile.ReadLine(), sym);
break;
case Converter.MultiCharts:
k = MultiCharts.parseline(infile.ReadLine(), _sym);
break;
}
}
catch (Exception ex) { bads++; continue; }
if (k == null)
{
debug("Invalid converter: " + con.ToString());
return false;
//.........这里部分代码省略.........
示例2: convert
bool convert(Converter con, string filename,int tradesize)
{
int bads = 0;
int thistotal = _ticksprocessed;
bool g = true;
// get output filename
string convertname = string.Empty;
// setup writing to output
TikWriter outfile = null;
// setup input file
StreamReader infile = null;
try
{
// open input file
switch (con)
{
case Converter.TradeStation:
infile = new StreamReader(filename);
// read in and ignore header of input file
infile.ReadLine();
break;
case Converter.eSignal_EPF:
infile = new StreamReader(filename);
// ignore header
SecurityImpl esec = eSigTick.InitEpf(infile);
_sym = esec.Symbol;
break;
case Converter.CQG:
infile = new StreamReader(filename);
// no header
break;
}
}
catch (Exception ex) { debug("error reading input header:" + ex.Message); g = false; }
// setup previous tick and current tick
Tick pk = new TickImpl();
Tick k = null;
do
{
try
{
// get next tick from the file
switch (con)
{
case Converter.CQG:
k = CQG.parseline(infile.ReadLine(), tradesize);
break;
case Converter.eSignal_EPF:
k = eSigTick.FromStream(_sym, infile);
break;
case Converter.TradeStation:
k = TradeStation.parseline(infile.ReadLine(), _sym, tradesize);
break;
}
}
catch (Exception ex) { bads++; continue; }
if (k == null)
{
debug("Invalid converter: " + con.ToString());
return false;
}
// bad tick
if (k.date == 0) { bads++; continue; }
// if dates don't match, we need to write new output file
if (k.date != pk.date)
{
try
{
// if the outfile was open previously, close it
if (outfile != null)
outfile.Close();
// get path from input
string path = Path.GetDirectoryName(filename) + "\\";
// setup new file
outfile = new TikWriter(path,k.symbol, k.date);
// report progress
progress((double)_ticksprocessed / _approxtotal);
}
catch (Exception ex) { debug(ex.Message); g = false; }
}
try
{
// write the tick
outfile.newTick(k);
// save this tick as previous tick
pk = k;
// count the tick as processed
_ticksprocessed++;
}
catch (Exception ex) { debug("error writing output tick: " + ex.Message); g = false; }
}
// keep going until input file is exhausted
while (!infile.EndOfStream);
// close output file
outfile.Close();
// close input file
infile.Close();
//.........这里部分代码省略.........