当前位置: 首页>>代码示例>>C#>>正文


C# CsvRow.Clear方法代码示例

本文整理汇总了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;
     }
 }
开发者ID:ddksaku,项目名称:canon,代码行数:45,代码来源:CsvParser.cs

示例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);
             }
         }
     }
 }         
开发者ID:Ryanman,项目名称:CustomTools.AlignMigration,代码行数:35,代码来源:AlignMigration.cs


注:本文中的CsvRow.Clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。