Example #1
0
        private void GenerationWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;
            IMessageFilter   oldFilter;
            int ret = CoRegisterMessageFilter(new RetryMessageFilter(), out oldFilter);

            // Debugger.Log(10, "debug", ret.ToString());

            try
            {
                string outputfolder = SolutionGenerator.GenerateSolution();

                worker.ReportProgress(40);

                if (outputfolder == String.Empty)
                {
                    throw new Exception("Something went wrong around the specified output folder...");
                }

                if (SolutionGenerator.SelectedInterface == ComponentInterface.Dependent)
                {
                    SolutionGenerator.GenerateDomainSpecificInterface();
                }
                worker.ReportProgress(60);

                SolutionGenerator.PostProcessComponentConfig(outputfolder);
                worker.ReportProgress(70);

                SolutionGenerator.RenameProject(outputfolder);
                worker.ReportProgress(80);

                SolutionGenerator.GenerateSignature(outputfolder);
                worker.ReportProgress(95);
            }
            catch (Exception ex)
            {
                object[] args = new object[1];
                args[0] = ex.Message;
                this.Dispatcher.Invoke(erroroccureddel, args);
            }
            finally
            {
                File.Delete(Path.Combine(SolutionGenerator.ProjectTemplateLocation, SolutionGenerator.TemplateFileName));
                worker.ReportProgress(100);
            }
        }
Example #2
0
        public static void RenameProject(string outputfolder)
        {
            if (SolutionGenerator.SelectedType == CompType.Addon)
            {
                // Rename namespace, classname, and filename
                StreamReader ComponentConfigReadStream = new StreamReader(Path.Combine(outputfolder, "MyAddon.cs"));
                string       ContentString             = ComponentConfigReadStream.ReadToEnd();
                ComponentConfigReadStream.Close();

                ContentString = ContentString.Replace("MyAddon : IMgaComponentEx", SolutionName + "Addon : IMgaComponentEx");
                ContentString = ContentString.Replace("MyAddon", SolutionName);

                StreamWriter ComponentConfigWriteStream = new StreamWriter(Path.Combine(outputfolder, "MyAddon.cs"));
                ComponentConfigWriteStream.Write(ContentString);
                ComponentConfigWriteStream.Close();

                File.Move(Path.Combine(outputfolder, "MyAddon.cs"), Path.Combine(outputfolder, SolutionName + ".cs"));


                // Rename filereference in the csproj file
                ComponentConfigReadStream = new StreamReader(Path.Combine(outputfolder, SolutionName + ".csproj"));
                ContentString             = ComponentConfigReadStream.ReadToEnd();
                ComponentConfigReadStream.Close();

                ContentString = ContentString.Replace("MyAddon", SolutionName);

                // Uncomment signature
                ContentString = ContentString.Replace("<!--DELETE", "");
                ContentString = ContentString.Replace("DELETE-->", "");

                ComponentConfigWriteStream = new StreamWriter(Path.Combine(outputfolder, SolutionName + ".csproj"));
                ComponentConfigWriteStream.Write(ContentString);
                ComponentConfigWriteStream.Close();
            }
            else // interpreter
            {
                // Rename namespace, classname, and filename
                StreamReader FileReadStream = new StreamReader(Path.Combine(outputfolder, "MyInterpreter.cs"));
                string       ContentString  = FileReadStream.ReadToEnd();
                FileReadStream.Close();

                ContentString = ContentString.Replace("MyInterpreter : IMgaComponentEx", SolutionName + "Interpreter : IMgaComponentEx");
                ContentString = ContentString.Replace("MyInterpreter", SolutionName);
                ContentString = SolutionGenerator.AddEntryPointCode(ContentString);

                StreamWriter FileWriteStream = new StreamWriter(Path.Combine(outputfolder, "MyInterpreter.cs"));
                FileWriteStream.Write(ContentString);
                FileWriteStream.Close();

                File.Move(Path.Combine(outputfolder, "MyInterpreter.cs"), Path.Combine(outputfolder, SolutionName + ".cs"));


                // Rename filereference in the csproj file
                FileReadStream = new StreamReader(Path.Combine(outputfolder, "" + SolutionName + ".csproj"));
                ContentString  = FileReadStream.ReadToEnd();
                FileReadStream.Close();

                ContentString = ContentString.Replace("MyInterpreter", SolutionName);

                // Uncomment signature reference
                ContentString = ContentString.Replace("<!--DELETE", "");
                ContentString = ContentString.Replace("DELETE-->", "");

                FileWriteStream = new StreamWriter(Path.Combine(outputfolder, "" + SolutionName + ".csproj"));
                FileWriteStream.Write(ContentString);
                FileWriteStream.Close();
            }
        }