本文整理汇总了C#中CsvRow.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# CsvRow.Clear方法的具体用法?C# CsvRow.Clear怎么用?C# CsvRow.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CsvRow
的用法示例。
在下文中一共展示了CsvRow.Clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PerformAction
private static void PerformAction(ref int intCurrState, char chrInputChar, ref StringBuilder strElem, ref CsvRow alParsedCsv)
{
string strTemp = null;
switch (intCurrState)
{
case 0:
//Seperate out value to array list
strTemp = strElem.ToString();
alParsedCsv.Add(strTemp);
strElem = new StringBuilder();
break;
case 1:
case 3:
case 4:
//accumulate the character
strElem.Append(chrInputChar);
break;
case 5:
//End of line reached. Seperate out value to array list
strTemp = strElem.ToString();
alParsedCsv.Add(strTemp);
break;
case 6:
//Erroneous input. Reject line.
alParsedCsv.Clear();
break;
case 7:
//wipe ending " and Seperate out value to array list
strElem.Remove(strElem.Length - 1, 1);
strTemp = strElem.ToString();
alParsedCsv.Add(strTemp);
strElem = new StringBuilder();
intCurrState = 5;
break;
case 8:
//wipe ending " and Seperate out value to array list
strElem.Remove(strElem.Length - 1, 1);
strTemp = strElem.ToString();
alParsedCsv.Add(strTemp);
strElem = new StringBuilder();
//goto state 0
intCurrState = 0;
break;
}
}
示例2: WritePlansAndAllLinks
/// <summary>
/// Writes a .json file containing all the test plans (and their cases) migrated using TCM.exe
/// The test cases inside the plans use our custom book keeping structure, MigrationWorkItem.
/// Also writes a CSV File performing the same thing.
/// </summary>
/// <param name="jsonPath">Path of the JSON, originally defined in app.config or altered at runtime</param>
/// <param name="csvPath">Path of the csv, originally defined in app.config or altered at runtime</param>
/// <param name="testPlans">A collection of test plans, each with MigrationWorkItems inside</param>
private static void WritePlansAndAllLinks(string jsonPath, string csvPath, List<MigrationTestPlan> testPlans)
{
Trace.WriteLine("\nWriting Plans and Cases to: \n\t" + jsonPath
+ "\n\tand\n\t" + csvPath);
CsvRow row = new CsvRow();
row.AddRange(new string[] { "Test Plan Name", "Old ID", "New ID", "Old Area Path" });
using (FileStream csvStream = File.Open(csvPath, FileMode.OpenOrCreate))
using (CsvFileWriter cw = new CsvFileWriter(csvStream))
using (FileStream jsonStream = File.Open(jsonPath, FileMode.OpenOrCreate))
using (StreamWriter sw = new StreamWriter(jsonStream))
using (JsonWriter jw = new JsonTextWriter(sw))
{
cw.WriteRow(row);
foreach (var testPlan in testPlans)
{
jw.Formatting = Formatting.Indented;
JsonSerializer serializer = new JsonSerializer();
serializer.Serialize(jw, testPlan);
foreach (var testCase in testPlan.TestCases)
{
row.Clear();
row.AddRange(new string[] { testPlan.TestPlanName, testCase.OldID, testCase.NewID, testCase.OldItemAreaPath });
cw.WriteRow(row);
}
}
}
}