public void InjectScripts(string fullSourceCode, string repxFileName, bool replaceOriginal = false)
        {
            if (fullSourceCode == null)
                throw new ArgumentNullException("fullSourceCode");
            if (!fullSourceCode.Contains(XtraReportSyncMarkers.StartMarker))
                throw new ArgumentException("fullSourceCode does not contain a valid ScriptSourceStartMarker");
            if (!fullSourceCode.Contains(XtraReportSyncMarkers.EndMarker))
                throw new ArgumentException("fullSourceCode does not contain a valid ScriptSourceEndMarker");

            XtraReportScriptParser parser = new XtraReportScriptParser();
            string collectedUsingReferences = parser.CollectUsingReferences(fullSourceCode);
            string scriptSource = parser.RemoveIgnoredSections(fullSourceCode);
            scriptSource = parser.MaximumUnindent(scriptSource);
            scriptSource = Environment.NewLine + collectedUsingReferences + Environment.NewLine + scriptSource;

            var temporaryReportFileName = Path.ChangeExtension(Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()), ".repx");
            Report.ScriptsSource = scriptSource;
            try
            {
                Report.SaveLayout(temporaryReportFileName);
                AssertReportContainsScriptSource(temporaryReportFileName, scriptSource);
                if (replaceOriginal)
                    File.Copy(temporaryReportFileName, repxFileName, true);
            }
            finally
            {
                File.Delete(temporaryReportFileName);
            }
        }
 private string GetScriptSection()
 {
     StringBuilder sb = new StringBuilder();
     sb.AppendLine();
     sb.AppendLine("// -- Anything above this line will be ignored when converting back to repx. --");
     sb.AppendLine(XtraReportSyncMarkers.StartMarker);
     var parser = new XtraReportScriptParser();
     sb.AppendLine(parser.MaximumUnindent(ScriptExtractor.ExtractScripts()));
     sb.AppendLine(XtraReportSyncMarkers.EndMarker);
     sb.AppendLine("// -- Anything below this line will be ignored when converting back to repx. --");
     sb.AppendLine();
     return sb.ToString();
 }