private void CompileAndMergeCUnit(CodeDomProvider provider, CodeCompileUnit cunit, string fileName) { MergeableFile mergeableFile = new MergeableFile(fileName, true); StreamWriter sw = new StreamWriter(mergeableFile.Stream); try { CodeGeneratorOptions cgo = new CodeGeneratorOptions(); cgo.BracingStyle = "C"; provider.GenerateCodeFromCompileUnit(cunit, sw, cgo); sw.Flush(); } catch (Exception ex) { sw.Close(); mergeableFile.Restore(); throw ex; } if (mergeableFile.Write()) { this.filesWithConflicts.Add(fileName); } sw.Close(); }
public void Save() { XmlDocument doc = new XmlDocument(); this.project.Save(doc); Merge.CommentPrefix = "<!--"; MergeableFile mergeableFile = new MergeableFile(fileName); try { doc.Save(mergeableFile.Stream); } catch (Exception ex) { mergeableFile.Restore(); mergeableFile.Stream.Close(); throw ex; } this.hasConflicts = mergeableFile.Write(); mergeableFile.Stream.Close(); }