Exemplo n.º 1
0
        public static void GenerateDomainSpecificInterface()
        {
            try
            {
                // Overwrite ParadigmName if DS interface is generated
                SolutionGenerator.ParadigmName = GeneratorFacade.main(MgaPath, TargetFolder + @"\" + SolutionName, "GME.CSharp." + SolutionName);

                if (GeneratorFacade.Errors.Count != 0)
                {
                    throw new Exception("Error occured during the domain specific interface generation.");
                }
            }
            catch (Exception)
            {
                object[] args = new object[1];
                args[0] = GeneratorFacade.Errors;
                if (GeneratorFacade.Errors.Count != 0)
                {
                    SolutionGenerator.mw.Dispatcher.Invoke(SolutionGenerator.mw.errorwindowdel, args);
                }
                throw;
            }

            // Add files to the projectfile
            string AddString = String.Empty;

            foreach (string s in GeneratorFacade.generatedFiles)
            {
                AddString += "\t<Compile Include=\"" + ParadigmName + @"\";
                AddString += System.IO.Path.GetFileName(s);
                AddString += "\" />";
                AddString += Environment.NewLine;
            }

            try
            {
                // Rename filereference in the csproj file
                StreamReader FileReadStream = new StreamReader(Path.Combine(TargetFolder, SolutionName) + @"\" + SolutionName + ".csproj");
                string       ContentString  = FileReadStream.ReadToEnd();
                FileReadStream.Close();

                ContentString = ContentString.Replace(@"<!--$ADDITIONALFILES$-->", AddString);

                StreamWriter FileWriteStream = new StreamWriter(Path.Combine(TargetFolder, SolutionName) + @"\" + SolutionName + ".csproj");
                FileWriteStream.Write(ContentString);
                FileWriteStream.Close();
            }
            catch (Exception)
            {
                MessageBox.Show("Error occured: Cannot find the previously generated VS projectfile in the specified folder with the specified solutionname.");
                throw;
            }
        }