本文整理汇总了C#中CsvRow.IndexOf方法的典型用法代码示例。如果您正苦于以下问题:C# CsvRow.IndexOf方法的具体用法?C# CsvRow.IndexOf怎么用?C# CsvRow.IndexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CsvRow
的用法示例。
在下文中一共展示了CsvRow.IndexOf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: populatedatabaseline
/// <summary>
/// populating data for the baseline file values
/// </summary>
/// <param name="filename"></param>
private void populatedatabaseline(string filename)
{
//clear the values id needed
if(wantedcolumnsbl.Count > 0)
wantedcolumnsbl.Clear();
if(realpowerdictbl.Count > 0)
realpowerdictbl.Clear();
if (colobjinterflistbl.Count > 0)
colobjinterflistbl.Clear();
if (!(File.Exists(filename)))
{
MessageBox.Show("The baseline file: !exist");
return;
}
//datacolumnsbl comes from xml so do not clear it
foreach (Column c in datacolumnsbl.namealiaslist)
{
//Clear the values in the columns
c.clearvalues();
wantedcolumnsbl.Add(c);
}
// Read sample data from CSV file
using (CsvFileReader reader = new CsvFileReader(filename))
{
CsvRow row = new CsvRow();
rowcount = 0;
while (reader.ReadRow(row))
{
if (rowcount == 0)
{
foreach (string s in row)
{
//the first row is the header
foreach (Column c in wantedcolumnsbl)
//if the name is in the wanted columns save position
if (c.columnname == s)
c.columnnumber = row.IndexOf(s);
}
}
else
{
foreach (Column c in wantedcolumnsbl)
{
c.colvalues.Add(row[c.columnnumber]);
}
}
rowcount++;
}
Richtextedit("Baseline rows imported: " + Convert.ToString(rowcount));
}
foreach (Column c in wantedcolumnsbl)
{
realpowerdictbl.Add(c.alias, c);
}
foreach (var VAR in realpowerdictbl)
{
/// <summary>
/// Below the instance is created and!!! the parameter is passes to it. I like it.
/// VAR.Value.Columnvalues is the value
/// </summary>
//columnobjectlistbl.Add((Baselist)Activator.CreateInstance(Type.GetType("PlotDVT." + VAR.Key), VAR.Value.Columnvalues));
if (VAR.Key == "Vdcconfigured")
{
///if it is Vdcconfigured, add it as VdcConfigured, some extra functionaly in Vdcconfigure
colobjinterflistbl.Add((IBaselist)Activator.CreateInstance
(Type.GetType("PlotDVT.VdcconfiguredI"), VAR.Value.Columnvalues, VAR.Key));
}
else if (VAR.Key == "Phaseconfigured")
{
///if it is Phaseconfigured add it as PhaseCongfigured, some extra functionaly in PhaseCongfigured
colobjinterflistbl.Add((IBaselist)Activator.CreateInstance
(Type.GetType("PlotDVT.PhaseconfiguredI"), VAR.Value.Columnvalues, VAR.Key));
}
else
{
//Add the rest just as ValuelistI
colobjinterflistbl.Add((IBaselist)Activator.CreateInstance(Type.GetType("PlotDVT.ValuelistI"), VAR.Value.Columnvalues, VAR.Key));
}
}
foreach (IBaselist Ibl in colobjinterflistbl)
{
if (Ibl.GetName() == "Phaseconfigured")
{
//Find Vdcconfigure to get slice parameters
foreach (IBaselist Ibltwo in colobjinterflistbl)
{
if (Ibltwo.GetName() == "Vdcconfigured")//if it is vdc configured
{
(Ibltwo as VdcconfiguredI).Setphaseslice((Ibl as PhaseconfiguredI).Listslices);//set first set
(Ibltwo as VdcconfiguredI).Setphaseslice((Ibl as PhaseconfiguredI).Listslices2);//set second set
}
//.........这里部分代码省略.........
示例2: populatedatatestunit
//************************************Done populating data for baseline*********************
//************************************Start populating UUT instances with data*************
/// <summary>
/// Populate data for the unit under test
/// </summary>
/// <param name="filename"></param>
private void populatedatatestunit(string filename)
{
//clear the old values
if (wantedcolumns.Count > 0)
wantedcolumns.Clear();
if (realpowerdict.Count > 0)
realpowerdict.Clear();
if (colobjinterflist.Count > 0)
colobjinterflist.Clear();
if (!(File.Exists(filename)))
{
MessageBox.Show("The data file: !exist");
return;
}
//datacolumnsbl come from xml so do not clear it
foreach (Column c in datacolumns.namealiaslist)
{
//Clear the values in the columns
c.clearvalues();
wantedcolumns.Add(c);
}
// Read data from CSV file
using (CsvFileReader reader = new CsvFileReader(filename))
{
CsvRow row = new CsvRow();
rowcount = 0;
while (reader.ReadRow(row))
{
//if the row count is 0, then headers
if (rowcount == 0)
{
foreach (string s in row)
{
//the first row is the header
foreach (Column c in wantedcolumns)
//if the name is in the wanted columns save position
if (c.columnname == s)
c.columnnumber = row.IndexOf(s);
}
}
else
{
foreach (Column c in wantedcolumns)
{
c.colvalues.Add(row[c.columnnumber]);
}
}
rowcount++;
}
Richtextedit("Datarows imported: " + Convert.ToString(rowcount));
}
foreach (Column c in wantedcolumns)
{
realpowerdict.Add(c.alias, c);
}
//Uses the CSVrowManager to load all the wanted data as they exist in rows
CSVrowManager = new CSVrowManager();
CSVrowManager.Load(wantedcolumns);
//columnobjectlist = new List<Baselist>();
foreach (var VAR in realpowerdict)
{
/// <summary>
/// Below the instance is created and!!! the parameter is passes to it. I like it.
/// VAR.Value.Columnvalues is the value
/// </summary>
//columnobjectlist.Add((Baselist)Activator.CreateInstance(Type.GetType("PlotDVT." + VAR.Key), VAR.Value.Columnvalues));
if(VAR.Key == "Vdcconfigured")
{
colobjinterflist.Add((IBaselist)Activator.CreateInstance
(Type.GetType("PlotDVT.VdcconfiguredI"), VAR.Value.Columnvalues, VAR.Key));
}
else if (VAR.Key == "Phaseconfigured")
{
colobjinterflist.Add((IBaselist)Activator.CreateInstance
(Type.GetType("PlotDVT.PhaseconfiguredI"), VAR.Value.Columnvalues, VAR.Key));
}
else
{
colobjinterflist.Add((IBaselist)Activator.CreateInstance(Type.GetType("PlotDVT.ValuelistI"), VAR.Value.Columnvalues, VAR.Key));
}
}
foreach (IBaselist Ibl in colobjinterflist)
{
if (Ibl.GetName() == "Phaseconfigured")
{
//Find Vdcconfigure to get slice parameters
foreach (IBaselist Ibltwo in colobjinterflist)
{
if (Ibltwo.GetName() == "Vdcconfigured")
//.........这里部分代码省略.........