/// <summary>
        ///
        /// </summary>
        /// <param name="inputProject"></param>
        /// <returns> path to .exe file </returns>
        public Tuple <string, LogProcess> Process(IProject inputProject)
        {
            List <IFile> listCsFiles = SearchFile.Search(inputProject.RootFolder,
                                                         new CsFileSearchCondition());
            List <CsClass> screens = new List <CsClass>();

            List <CsFile> listCsFilesNeedToModify = new List <CsFile>();

            foreach (IFile file in listCsFiles)
            {
                CsFileAnalyzer csFileAnalyzer = new CsFileAnalyzer();
                CsFile         csFile         = (CsFile)file;
                csFileAnalyzer.CsFile = csFile;
                csFileAnalyzer.Process();
                foreach (CsClass csClass in csFile.Classes)
                {
                    if (csClass.BaseOnClass != null && (
                            csClass.BaseOnClass.Contains(CsClass.WINDOW_CLASS) |
                            csClass.BaseOnClass.Contains(CsClass.FORM_CLASS)))
                    {
                        screens.Add(csClass);
                        if (!listCsFilesNeedToModify.Contains(file))
                        {
                            listCsFilesNeedToModify.Add((CsFile)file);
                        }
                    }
                }
            }

            ModifyProject(inputProject, screens, listCsFilesNeedToModify);
            return(RebuildProject(inputProject));
        }
        /// <summary>
        /// append 2 statements:
        ///     System.IO.File.AppendAllText("temp_file_155133.txt", "ThisWindow");
        ///     Open_All_Windows(); //call to function which open all other window
        /// </summary>
        /// <param name="csFile"></param>
        /// <param name="listWindows"></param>
        /// <param name="tempFileName"></param>
        /// <returns></returns>
        public bool ModifyConstructorFunc(CsFile csFile, List <CsClass> listWindows, string tempFileName)
        {
            try
            {
                //The code that causes the error goes here.
                SyntaxTree tree = CSharpSyntaxTree.ParseText(
                    Utils.ReadFileContent(csFile.Path));
                var root         = (CompilationUnitSyntax)tree.GetRoot();
                var classRewrite = new ClassRewriter();
                classRewrite.ListWindows  = listWindows;
                classRewrite.TempFileName = tempFileName;
                SyntaxNode newRoot = classRewrite.Visit(root);

                //var workspace = MSBuildWorkspace.Create();
                //SyntaxNode formattedNode = Formatter.Format(newRoot, workspace);
                //logger.Debug("abc: " + formattedNode);

                System.IO.File.WriteAllText(csFile.Path, Utils.ReformatCsCode(newRoot.ToFullString()));
                //formattedNode.ToFullString());
            }
            catch (ReflectionTypeLoadException ex)
            {
                StringBuilder sb = new StringBuilder();
                foreach (Exception exSub in ex.LoaderExceptions)
                {
                    sb.AppendLine(exSub.Message);
                    FileNotFoundException exFileNotFound = exSub as FileNotFoundException;
                    if (exFileNotFound != null)
                    {
                        if (!string.IsNullOrEmpty(exFileNotFound.FusionLog))
                        {
                            sb.AppendLine("Fusion Log:");
                            sb.AppendLine(exFileNotFound.FusionLog);
                        }
                    }
                    sb.AppendLine();
                }
                string errorMessage = sb.ToString();
                //Display or log the error based on your application.
            }
            return(true);
        }
 public WindowWpf(string name, CsFile csFileCode, string fullName)
 {
     this.name       = name;
     this.csFileCode = csFileCode;
     this.fullName   = fullName;
 }
示例#4
0
 public FormWfa(CsFile csFileCode, string name)
 {
     this.csFileCode = csFileCode;
     this.name       = name;
 }