本文整理汇总了C#中Microsoft.VisualBasic.FileIO.TextFieldParser.ReadLine方法的典型用法代码示例。如果您正苦于以下问题:C# TextFieldParser.ReadLine方法的具体用法?C# TextFieldParser.ReadLine怎么用?C# TextFieldParser.ReadLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.VisualBasic.FileIO.TextFieldParser
的用法示例。
在下文中一共展示了TextFieldParser.ReadLine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Read
public IEnumerable<Brand> Read()
{
using (TextFieldParser parser = new TextFieldParser(path))
{
parser.CommentTokens = new string[] { "#" };
parser.SetDelimiters(new string[] { ";" });
parser.HasFieldsEnclosedInQuotes = true;
// Skip over header line.
parser.ReadLine();
while (!parser.EndOfData)
{
string[] fields = parser.ReadFields();
yield return new Brand()
{
Name = fields[0],
FactoryLocation = fields[1],
EstablishedYear = int.Parse(fields[2]),
Profit = double.Parse(fields[3], swedishCulture)
};
}
}
}
示例2: ReadFile
public void ReadFile()
{
if (FilePath == null) return;
var parser = new TextFieldParser(FilePath)
{
TextFieldType = FieldType.Delimited,
CommentTokens = new[] {"#"}
};
parser.SetDelimiters(",");
parser.HasFieldsEnclosedInQuotes = false;
parser.ReadLine();
while (!parser.EndOfData)
{
var row = parser.ReadFields();
if (row == null) continue;
var newLine = new List<string>(row.Length);
newLine.AddRange(row);
_data.Add(newLine);
}
}
示例3: AnimationData
static AnimationData()
{
Fallback = new Dictionary<ushort, ushort>();
NameToId = new Dictionary<string, ushort>();
IdToName = new Dictionary<ushort, string>();
PlayThenStop = new HashSet<ushort>();
PlayBackwards = new HashSet<ushort>();
var assembly = Assembly.GetExecutingAssembly();
var embeddedStream = assembly.GetManifestResourceStream("M2Lib.src.csv.AnimationData.csv");
Debug.Assert(embeddedStream != null, "Could not open embedded ressource AnimationData");
var csvParser = new TextFieldParser(embeddedStream) {CommentTokens = new[] {"#"}};
csvParser.SetDelimiters(",");
csvParser.HasFieldsEnclosedInQuotes = true;
csvParser.ReadLine(); // Skip first line
while (!csvParser.EndOfData)
{
var fields = csvParser.ReadFields();
Debug.Assert(fields != null);
var id = Convert.ToUInt16(fields[0]);
var name = fields[1];
var fallback = Convert.ToUInt16(fields[3]);
Fallback[id] = fallback;
NameToId[name] = id;
IdToName[id] = name;
}
csvParser.Close();
ushort[] playThenStopValues =
{
NameToId["Dead"],
NameToId["SitGround"],
NameToId["Sleep"],
NameToId["KneelLoop"],
NameToId["UseStandingLoop"],
NameToId["Drowned"],
NameToId["LootHold"]
};
foreach (var value in playThenStopValues) PlayThenStop.Add(value);
ushort[] playBackwardsValues =
{
NameToId["Walkbackwards"],
NameToId["SwimBackwards"],
NameToId["SleepUp"],
NameToId["LootUp"]
};
foreach (var value in playBackwardsValues) PlayBackwards.Add(value);
//TODO FIXME There a loops by following the fallbacks in AnimationData.dbc. Happens with Close and FlyClose.
Fallback[146] = 0;//Close
Fallback[375] = 0;//FlyClose
}
示例4: ParseCsv
public static IEnumerable<string[]> ParseCsv(string path, string delimiters = ",", bool hasHeader = true, bool hasFieldsEnclosedInQuotes = true)
{
using (var parser = new TextFieldParser(new StringReader(path)))
{
parser.SetDelimiters(delimiters);
parser.HasFieldsEnclosedInQuotes = hasFieldsEnclosedInQuotes;
if (hasHeader)
parser.ReadLine();
while (!parser.EndOfData)
{
var fields = parser.ReadFields();
if (fields != null)
yield return fields;
}
}
}
示例5: Parse
public IEnumerable<Quote> Parse(string csvBody)
{
using (TextFieldParser parser = new TextFieldParser(
new MemoryStream(Encoding.UTF8.GetBytes(csvBody))))
{
parser.CommentTokens = new[] { "#" };
parser.SetDelimiters(",");
parser.HasFieldsEnclosedInQuotes = true;
// Skip over header line.
parser.ReadLine();
while (!parser.EndOfData)
{
string[] fields = parser.ReadFields();
Quote q = null;
try
{
if (fields != null)
{
var date = ExtractDate(fields[0]);
if (date != DateTime.MinValue)
{
q = new Quote
{
Date = date,
Close = double.Parse(fields[1]),
Volume = double.Parse(fields[2]),
Open = double.Parse(fields[3]),
High = double.Parse(fields[4]),
Low = double.Parse(fields[5]),
};
}
}
}
catch (Exception)
{
// ignored
}
if (q != null)
yield return q;
}
}
}
示例6: Parse
/*
"Symbol","Name","LastSale","MarketCap","ADR TSO","IPOyear","Sector","industry","Summary Quote",
"DDD","3D Systems Corporation","28.38","3156341099.34","n/a","n/a","Technology","Computer Software: Prepackaged Software","http://www.nasdaq.com/symbol/ddd",
*/
public IEnumerable<Company> Parse(string csvCompanyList)
{
using (var parser = new TextFieldParser(
new MemoryStream(Encoding.UTF8.GetBytes(csvCompanyList))))
{
parser.CommentTokens = new[] { "#" };
parser.SetDelimiters(",");
parser.HasFieldsEnclosedInQuotes = true;
// Skip over header line.
parser.ReadLine();
while (!parser.EndOfData)
{
string[] fields = parser.ReadFields();
Company company = null;
try
{
if (fields != null)
{
company = new Company
{
Symbol = fields[0].Trim().ToUpper(),
Name = fields[1].Trim(),
LastSale = double.Parse(fields[2]),
MarketCap = double.Parse(fields[3]),
AdrTso = fields[4],
IPOyear = fields[5],
Sector = fields[6],
Industry = fields[7],
SummaryUrl = fields[8],
};
}
}
catch (Exception)
{
// ignored
}
if(company != null)
yield return company;
}
}
}
示例7: GetStateTaxRates
public static Dictionary<string, double> GetStateTaxRates(String filename)
{
if (! File.Exists(filename))
{
throw new Exception("file not found: " + filename, new FileNotFoundException());
}
var stateTaxRates = new Dictionary<string, double>();
using (var parser = new TextFieldParser(filename))
{
parser.TextFieldType = FieldType.Delimited;
parser.SetDelimiters(",");
bool firstRow = true;
while (! parser.EndOfData)
{
if (firstRow) // skip header
{
parser.ReadLine();
firstRow = false;
continue;
}
String[] fields = parser.ReadFields();
if (fields.Length >= 2) // (i.e. state, taxRate)
{
string state = fields[0].Trim();
double taxRate = Convert.ToDouble(fields[1].Trim());
stateTaxRates.Add(state, taxRate);
}
else
{
throw new Exception("unexpected field length" + fields.Length + " in " + filename);
}
}
}
return stateTaxRates;
}
示例8: LoadImageDS
public static Dictionary<string, List<ImageRow>> LoadImageDS()
{
var result = new Dictionary<string, List<ImageRow>>();
using (var parser = new TextFieldParser(@"C:\Users\Paul\Desktop\Datasets\images.csv"))
{
parser.CommentTokens = new string[] { "#" };
parser.SetDelimiters(new string[] { "," });
parser.HasFieldsEnclosedInQuotes = true;
parser.ReadLine();
while (!parser.EndOfData)
{
var fields = parser.ReadFields();
var row = new ImageRow();
row.Country = fields[0];
row.Caption = fields[1];
row.Credit = fields[2];
row.Url = fields[3];
if (result.ContainsKey(row.Country))
{
result[row.Country].Add(row);
}
else
{
var list = new List<ImageRow>();
list.Add(row);
result.Add(row.Country, list);
}
}
}
return result;
}
示例9: ParseDataFile
private static IList<CountryOrRegionGdpData> ParseDataFile(FileInfo fileInfoData)
{
IList<CountryOrRegionGdpData> toReturn = new List<CountryOrRegionGdpData>();
using (TextFieldParser parser = new TextFieldParser(fileInfoData.FullName))
{
parser.SetDelimiters("\t");
// Skip first line since it only contains headers
parser.ReadLine();
NumberFormatInfo numberFormatInfo = new NumberFormatInfo()
{
NumberDecimalSeparator = ".",
};
while (!parser.EndOfData)
{
string[] fields = parser.ReadFields();
toReturn.Add(new CountryOrRegionGdpData()
{
CountryCode = fields[3],
CountryName = fields[2],
GdpYear1960 = string.IsNullOrWhiteSpace(fields[5]) ? (decimal?)null : Convert.ToDecimal(fields[5], numberFormatInfo),
GdpYear1970 = string.IsNullOrWhiteSpace(fields[15]) ? (decimal?)null : Convert.ToDecimal(fields[15], numberFormatInfo),
GdpYear1980 = string.IsNullOrWhiteSpace(fields[25]) ? (decimal?)null : Convert.ToDecimal(fields[25], numberFormatInfo),
GdpYear1990 = string.IsNullOrWhiteSpace(fields[35]) ? (decimal?)null : Convert.ToDecimal(fields[35], numberFormatInfo),
GdpYear2000 = string.IsNullOrWhiteSpace(fields[45]) ? (decimal?)null : Convert.ToDecimal(fields[45], numberFormatInfo),
GdpYear2010 = string.IsNullOrWhiteSpace(fields[55]) ? (decimal?)null : Convert.ToDecimal(fields[55], numberFormatInfo),
});
}
}
return toReturn;
}
示例10: Import
public IList<Trade> Import(Stream stream, Market market, IList<Exception> exceps)
{
var trades = new List<Trade>();
// need to convert stream first
var CsvStream = new MemoryStream();
DocumentConvererHelper.XlsToExt(stream, CsvStream, "csv", sheetIndex: 1);
CsvStream.Position = 0;
var parser = new TextFieldParser(CsvStream) { HasFieldsEnclosedInQuotes = true };
parser.SetDelimiters(Separator);
var emptyline = parser.ReadLine(); // skip first line
var titles = parser.ReadFields();
if (titles == null) return trades;
//Build Positions
var idx = 0;
var headers = new Dictionary<string, int>();
foreach (var s in titles) headers[s.ToLowerInvariant()] = idx++;
var cultInfo = GetCultureInfo(_params);
var asOfDate = SimpleDate.Today;
if (_params != null && _params.ContainsKey("AsOfDate"))
{
var ss = _params["AsOfDate"];
asOfDate = SimpleDate.Parse(ss);
}
while (!parser.EndOfData)
{
var items = parser.ReadFields();
var trade = FromString(items, headers, exceps, market, cultInfo, asOfDate);
if (trade != null) trades.Add(trade);
}
parser.Close();
//Aggregate trades
var allTrades = new List<Trade>();
foreach (var tr in trades)
{
bool found = false;
foreach (var vv in allTrades)
{
if (vv.BookId != tr.BookId) continue;
var vvDpeDesc = vv.GetProperty(DPEDescription);
var trDpeDesc = tr.GetProperty(DPEDescription);
if (vv.Product.PricingType.Equals("Swap") || vv.Product.PricingType.Equals("MTMCurrencySwap")
|| vv.Product.PricingType.Equals("FRA"))
{
if (vv.Product.Currency != tr.Product.Currency) continue;
if (vv.Product.ContractMaturity != tr.Product.ContractMaturity) continue;
var splits = vv.Product.Description.Split('(');
var osplits = tr.Product.Description.Split('(');
if (splits.Length > 0 && osplits.Length > 0)
{
if (splits[0] != osplits[0]) continue;
}
else continue;
}
else if (vv.Product is FXOption && vvDpeDesc != null && trDpeDesc != null)
{
if (!vvDpeDesc.Equals(trDpeDesc)) continue;
}
else if (vv.Product.Description != tr.Product.Description) continue;
vv.Quantity += tr.Quantity;
vv.SettleAmount += tr.SettleAmount;
if (vv.Product is SymmetryProduct && tr.Product is SymmetryProduct)
{
(tr.Product as SymmetryProduct).DetailQuantity += (vv.Product as SymmetryProduct).DetailQuantity;
}
if (vv.Product is FX)
{
var fx1 = vv.Product as FX;
var fx2 = tr.Product as FX;
fx1.PrimaryAmount += fx2.PrimaryAmount;
fx1.QuotingAmount += fx2.QuotingAmount;
}
found = true;
break;
}
if (!found) allTrades.Add(tr);
}
return allTrades;
}
示例11: PeekTest
public void PeekTest()
{
using (StringReader reader = new StringReader ("abcd" + Constants.vbNewLine + "efgh" + Constants.vbNewLine + "'comment" + Constants.vbNewLine + "after comment" + Constants.vbNewLine))
using (TextFieldParser t = new TextFieldParser (reader)) {
Assert.AreEqual ("a", t.PeekChars (1), "#01");
Assert.AreEqual ("a", t.PeekChars (1), "#02");
Assert.AreEqual ("ab", t.PeekChars (2), "#03");
Assert.AreEqual ("abcd", t.PeekChars (10), "#04");
Assert.AreEqual ("abcd", t.ReadLine (), "#05");
Assert.AreEqual ("ef", t.PeekChars (2), "#06");
try {
t.PeekChars (0);
} catch (ArgumentException ex){
Helper.RemoveWarning (ex);
} catch (Exception ex) {
Helper.RemoveWarning (ex);
Assert.Fail ("#07 - Expected 'ArgumentException'");
}
try {
t.PeekChars (-1);
} catch (ArgumentException ex) {
Helper.RemoveWarning (ex);
} catch (Exception ex) {
Helper.RemoveWarning (ex);
Assert.Fail ("#08 - Expected 'ArgumentException'");
}
Assert.AreEqual ("efgh", t.PeekChars (10), "#09");
Assert.AreEqual ("efgh", t.ReadLine (), "#10");
t.CommentTokens = new string [] {"'"};
Assert.AreEqual ("afte", t.PeekChars (4), "#11");
Assert.AreEqual ("'comment", t.ReadLine (), "#12");
Assert.AreEqual ("af", t.PeekChars (2), "#13");
Assert.AreEqual ("after comment", t.ReadLine (), "#14");
}
}
示例12: ImportGasRate
private void ImportGasRate(string path)
{
string fileLocation = Path.Combine(path, "GAS.csv");
if (!(File.Exists(fileLocation)))
{
MessageBox.Show("GAS.CSV file is missing");
return;
}
using (TextFieldParser csvParser = new TextFieldParser(fileLocation))
{
csvParser.CommentTokens = new string[] { "#" };
csvParser.SetDelimiters(new string[] { "," });
csvParser.HasFieldsEnclosedInQuotes = true;
// Skip the row if the first row has the column names
if (headerComboBox.Text == "Yes")
{
csvParser.ReadLine();
}
inserted = 0;
failed = 0;
//public static String utilCompanyTable = "UtilityCompany";
//public static String[] utilCompanyColumns = {"CompanyName", "IsElectricity", "IsGas", "IsWater"};
while (!csvParser.EndOfData)
{
// Read current line fields, pointer moves to the next line.
string[] fields = csvParser.ReadFields();
if (fields.Length == 1) break; // real record should have more than one column
int count = 0;
foreach (string field in fields)
{
if (field == "") { fields[count] = "0.0"; }
count = count + 1;
}
//check if the Utility company already existed in the database
// if not, insert the new one
int result = checkIfUtilCompanyExist(fields[2], 'G');
int utilCompanyID = -1;
switch (result)
{
case 0:
updateUtilCompany(fields[2], 'G');
utilCompanyID = getUtilCompanyID(fields[2], 'G');
break;
case 1:
utilCompanyID = getUtilCompanyID(fields[2], 'G');
break;
case -1:
utilCompanyID = insertUtilCompany(fields[2], 'G');
inserted = inserted + 1;
break;
default:
// system error
return;
}
// insert utility rate
int gasTierSetID = 6;
int uRateID = insertUtilRate(fields, 'G', utilCompanyID, path, gasTierSetID);
object[] tierRateValue = { 0.0, 0.0, 0.0, 0.0, 0.0 };
tierRateValue[0] = fields[21];
tierRateValue[1] = fields[24];
tierRateValue[2] = fields[27];
insertTierRate(tierRateValue, 'G', "Regular", uRateID); // G for Generation
tierRateValue[0] = fields[22];
tierRateValue[1] = fields[25];
tierRateValue[2] = fields[28];
insertTierRate(tierRateValue, 'G', "CARE", uRateID);
insertTierRate(tierRateValue, 'G', "CARE/Medical", uRateID);
tierRateValue[0] = fields[23];
tierRateValue[1] = fields[26];
tierRateValue[2] = fields[29];
insertTierRate(tierRateValue, 'G', "Senior", uRateID);
DateTime summerStartDate = new DateTime(utilStartDate.Year, 05, 01);
DateTime winterStartDate = new DateTime(utilStartDate.Year, 11, 01);
int x = 38;
if ((utilStartDate > summerStartDate) & (utilStartDate < winterStartDate))
{ x = 38; } // summer allowance rate column starts here
else
{ x = 68; } // winter allowance rate column starts here
Object[] value =
{uRateID,
'1', // All Services allowance
'1', // Zone
fields[x] // Allowance
};
for (int i = 0; i < 10; i = i + 1)
{
value[2] = i;
value[1] = '1'; // All Services allowance
value[3] = fields[x + 10 + i];
DatabaseControl.executeInsertQuery(DatabaseControl.baselineAllowanceTable, DatabaseControl.baselineAllowanceColumns, value);
value[1] = '2'; // Cooking only Services allowance
value[3] = fields[x + 20 + i];
DatabaseControl.executeInsertQuery(DatabaseControl.baselineAllowanceTable, DatabaseControl.baselineAllowanceColumns, value);
//.........这里部分代码省略.........
示例13: StartBenchmark
private void StartBenchmark(string args, string path)
{
StartGame(args, path);
// Parse the csv file generated by TF2.
var results = new FileInfo(path + @"\tf\sourcebench.csv");
if (!results.Exists)
{
WorkerThread.ReportProgress(0, "Benchmark results file not found.");
return;
}
using (var parser = new TextFieldParser(results.FullName))
{
parser.TextFieldType = FieldType.Delimited;
parser.SetDelimiters(",");
parser.HasFieldsEnclosedInQuotes = false;
parser.TrimWhiteSpace = true;
int lineCount = File.ReadLines(results.FullName).Count();
// Skip the first header line of the file.
parser.ReadLine();
while (parser.PeekChars(1) != null)
{
var li = new ListViewItem();
// Read every other line if benchmarking twice per command.
if (cb_runtwice.Checked && lineCount > 2 && parser.LineNumber % 2 == 0)
{
parser.ReadLine();
continue;
}
string[] row = parser.ReadFields();
for (int i = 0; i < row.Length; i++)
{
switch(i)
{
case 0:
li.Text = row[i];
break;
case 1: case 2: case 3: case 4: case 12: case 23:
li.SubItems.Add(row[i]);
break;
}
}
// Add the results to the listview.
if (lv_results.InvokeRequired)
{
lv_results.Invoke(new MethodInvoker(delegate
{
lv_results.Items.Add(li);
}));
}
else
lv_results.Items.Add(li);
}
}
}
示例14: openButton_Click
private void openButton_Click(object sender, EventArgs e)
{
List<string[]> parsedData = new List<string[]>();
try
{
// Detect the path of documents folder and assign it to initial directory path
String myDocument = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
openFile.InitialDirectory = myDocument;
if (openFile.ShowDialog() == DialogResult.OK)
{
Microsoft.VisualBasic.FileIO.TextFieldParser parser = new Microsoft.VisualBasic.FileIO.TextFieldParser(openFile.FileName);
parser.TextFieldType = FieldType.Delimited;
parser.SetDelimiters(",");
parser.TrimWhiteSpace = true;
parser.ReadLine();
parser.ReadLine();
parser.ReadLine();
parser.ReadLine();
parser.ReadLine();
parser.ReadLine();
parser.ReadLine();
parser.ReadLine();
parser.ReadLine();
parser.ReadLine();
parser.ReadLine();
parser.ReadLine();
parser.ReadLine();
while (!parser.EndOfData)
{
string[] fields = parser.ReadFields();
parsedData.Add(fields);
Trace.WriteLine(parsedData);
/*foreach (string field in fields)
{
parsedData.Add(field.ToString());
Trace.WriteLine(field);
}
*/
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
示例15: ParseGods
public static List<GodStat> ParseGods(string file)
{
List<GodStat> gods = new List<GodStat>();
using(StringReader reader = new StringReader(client.DownloadString(file))) {
using(TextFieldParser parser = new TextFieldParser(reader)) {
parser.TextFieldType = FieldType.Delimited;
parser.SetDelimiters(",");
parser.ReadLine();
while(!parser.EndOfData) {
int i = 0;
string[] fields = parser.ReadFields();
if(fields == null) throw new ArgumentException("not a valid file", "file");
GodStat god = new GodStat();
god.Name = fields[i++];
god.PowerType = (GodType)Enum.Parse(typeof(GodType), fields[i++], true);
god.BaseHealth = Double.Parse(fields[i++], CultureInfo.InvariantCulture);
god.HealthScaling = Double.Parse(fields[i++], CultureInfo.InvariantCulture);
god.BasePhysProtection = Double.Parse(fields[i++], CultureInfo.InvariantCulture);
god.PhysProtectionScaling = Double.Parse(fields[i++], CultureInfo.InvariantCulture);
god.BaseMagicalProtection = Double.Parse(fields[i++], CultureInfo.InvariantCulture);
god.MagicalProtectionScaling = Double.Parse(fields[i++], CultureInfo.InvariantCulture);
god.BaseAttackSpeed = Double.Parse(fields[i++], CultureInfo.InvariantCulture);
god.AttackSpeedScaling = Double.Parse(fields[i++], CultureInfo.InvariantCulture);
god.BaseAttack = Double.Parse(fields[i++], CultureInfo.InvariantCulture);
god.AttackScaling = Double.Parse(fields[i++], CultureInfo.InvariantCulture);
god.BaseMana = Double.Parse(fields[i++], CultureInfo.InvariantCulture);
god.ManaScaling = Double.Parse(fields[i++], CultureInfo.InvariantCulture);
GodAbility[] abilities = new GodAbility[4];
for(int a = 0; a < 4; a++) {
abilities[a] = new GodAbility();
abilities[a].Name = fields[i++];
abilities[a].BaseDamage = Double.Parse(fields[i++], CultureInfo.InvariantCulture);
abilities[a].Rank = Double.Parse(fields[i++], CultureInfo.InvariantCulture);
abilities[a].Scaling = Double.Parse(fields[i++], CultureInfo.InvariantCulture);
abilities[a].AbilityType = (AbilityType)Enum.Parse(typeof(AbilityType), fields[i++], true);
abilities[a].Refire = Double.Parse(fields[i++], CultureInfo.InvariantCulture);
abilities[a].Precast = Double.Parse(fields[i++], CultureInfo.InvariantCulture);
abilities[a].Postcast = Double.Parse(fields[i++], CultureInfo.InvariantCulture);
string duration = fields[i++];
abilities[a].Duration = duration == "" ? 0 : duration == "Infinite" ? Double.PositiveInfinity : Double.Parse(duration, CultureInfo.InvariantCulture);
}
god.FirstAbility = abilities[0];
god.SecondAbility = abilities[1];
god.ThirdAbility = abilities[2];
god.UltimateAbility = abilities[3];
god.Passive = fields[i++];
god.BaseHp5 = Double.Parse(fields[i++], CultureInfo.InvariantCulture);
god.Hp5Scaling = Double.Parse(fields[i], CultureInfo.InvariantCulture);
gods.Add(god);
}
}
}
using(StringReader reader = new StringReader(client.DownloadString("https://docs.google.com/spreadsheets/d/1a6LlTs8BNXHIwGicqM0TFXEvGwk77VXAxGxi0Xqd8Dk/export?format=csv&id=1a6LlTs8BNXHIwGicqM0TFXEvGwk77VXAxGxi0Xqd8Dk&gid=257000868"))) {
using(TextFieldParser parser = new TextFieldParser(reader)) {
parser.TextFieldType = FieldType.Delimited;
parser.SetDelimiters(",");
parser.ReadLine();
while(!parser.EndOfData) {
int i = 0;
string[] fields = parser.ReadFields();
if(fields == null) throw new ArgumentException("not a valid file", "file");
string name = fields[i++];
int god = gods.FindIndex(g => g.Name == name);
gods[god].FirstSteroid = new GodSteroid() {
Enabled = fields[i++],
Disabled = fields[i++]
};
gods[god].SecondSteroid = new GodSteroid() {
Enabled = fields[i++],
Disabled = fields[i++]
};
gods[god].FirstSpecial = new GodSpecial() {
Name = fields[i++],
BaseDamage = Double.Parse("0" + fields[i++], CultureInfo.InvariantCulture),
CastType = (AbilityType)Enum.Parse(typeof(AbilityType), CheckEnum(fields[i++]), true),
Precast = Double.Parse("0" + fields[i++], CultureInfo.InvariantCulture),
Postcast = Double.Parse("0" + fields[i++], CultureInfo.InvariantCulture),
Duration = Double.Parse("0" + fields[i++], CultureInfo.InvariantCulture)
};
//.........这里部分代码省略.........