コード例 #1
0
 public static void InitFill(StreamWriter sw)
 {
     foreach (string initFill in SolutionFileTemplateGenerator.InitFillList())
     {
         sw.WriteLine(initFill);
     }
 }
コード例 #2
0
 public static void GenerateSolutionFile(string slnFilePath)
 {
     if (!File.Exists(slnFilePath))
     {
         FileStream fileStream = (FileStream)null;
         SolutionFIleParser.readWriteLock.EnterWriteLock();
         try
         {
             fileStream = File.Create(slnFilePath);
         }
         finally
         {
             if (fileStream != null)
             {
                 fileStream.Close();
             }
             SolutionFIleParser.readWriteLock.ExitWriteLock();
         }
     }
     if (new FileInfo(slnFilePath).Length != 0L)
     {
         return;
     }
     using (StreamWriter sw = new StreamWriter(slnFilePath))
         SolutionFileTemplateGenerator.InitFill(sw);
 }
コード例 #3
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);
     }
 }