コード例 #1
0
 public static void AddProject(string slnFilePath, string projFilePath)
 {
     if (slnFilePath == null || projFilePath == null)
     {
         throw new ArgumentNullException("One of the arguments is null");
     }
     try
     {
         LinkedList <string> allLines1 = new LinkedList <string>();
         LinkedList <string> allLines2 = new LinkedList <string>();
         SolutionFIleParser.GenerateSolutionFile(slnFilePath);
         using (StreamReader streamReader = new StreamReader(slnFilePath))
         {
             string str1;
             while ((str1 = streamReader.ReadLine()) != "EndGlobal")
             {
                 allLines1.AddLast(str1);
             }
             allLines1.AddLast(str1);
             string str2;
             while ((str2 = streamReader.ReadLine()) != null)
             {
                 allLines2.AddLast(str2);
             }
         }
         if (SolutionFIleParser.changeRoot)
         {
             if (allLines2.Count == 0)
             {
                 allLines2 = SolutionFileTemplateGenerator.InitFillList();
             }
             SolutionFIleParser.Adding(allLines2, projFilePath);
         }
         else
         {
             SolutionFIleParser.Adding(allLines1, projFilePath);
         }
         using (StreamWriter streamWriter = new StreamWriter(slnFilePath))
         {
             foreach (string str in allLines1)
             {
                 streamWriter.WriteLine(str);
             }
             foreach (string str in allLines2)
             {
                 streamWriter.WriteLine(str);
             }
         }
     }
     catch (IOException ex)
     {
         Console.WriteLine(ex.Message);
     }
 }