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);
            }
        }
 public string GetScriptsCode()
 {
     string scriptSection = GetScriptSection();
     var parser = new XtraReportScriptParser();
     StringBuilder sb = new StringBuilder();
     sb.AppendLine("");
     sb.AppendLine(parser.CollectUsingReferences(scriptSection));
     sb.AppendLine();
     sb.AppendLine("namespace " + NamespaceHelper.Get() + "." + NameSpace + " {");
     sb.AppendLine("    public partial class " + ClassName);
     sb.AppendLine("    {");
     sb.AppendLine(parser.RemoveUsingReferences(scriptSection));
     sb.AppendLine("    }");
     sb.AppendLine("}");
     return sb.ToString();
 }