Beispiel #1
0
        private void Generate()
        {
            string slnDirectory;

            if (!TargetDirectory.EndsWith("\\") && !TargetDirectory.EndsWith("//"))
            {
                slnDirectory = TargetDirectory + "\\" + CustomBuilderName;
            }
            else
            {
                slnDirectory = TargetDirectory + CustomBuilderName;
            }

            if (Directory.Exists(slnDirectory))
            {
                throw new Exception(Resources.strError1);
            }

            Directory.CreateDirectory(slnDirectory);

            string projectDirectory = slnDirectory + "\\" + CustomBuilderName;

            Directory.CreateDirectory(projectDirectory);
            Directory.CreateDirectory(projectDirectory + "\\bin");
            Directory.CreateDirectory(projectDirectory + "\\bin\\Release\\" + CustomBuilderName);
            Directory.CreateDirectory(projectDirectory + "\\bin\\Debug");
            Directory.CreateDirectory(projectDirectory + "\\Properties");

            Hashtable vals = new Hashtable();

            vals.Add("CustomBuilderName", CustomBuilderName);
            vals.Add("CustomBuilderDescption", CustomBuilderDescption);
            vals.Add("RootNamespace", Namespace);
            vals.Add("COMGUID", Guid.NewGuid().ToString());
            vals.Add("ProjectGUID", "{" + Guid.NewGuid().ToString() + "}");
            vals.Add("StartProgram", AppDomain.CurrentDomain.BaseDirectory + "\\ADB.exe");
            vals.Add("StartArguments", string.Format("{0}\\bin\\debug\\{1}.builder", projectDirectory, CustomBuilderName));
            vals.Add("CustomBuilderProjectGUID", "{" + Guid.NewGuid().ToString() + "}");

            _tempSolution.SaveAs(slnDirectory + "\\" + CustomBuilderName + ".sln", Encoding.UTF8, vals);
            _tempReadme.SaveAs(slnDirectory + "\\readme.txt", Encoding.UTF8, vals);

            _tempProject.SaveAs(projectDirectory + "\\" + CustomBuilderName + ".csproj", Encoding.UTF8, vals);
            _tempProject_User.SaveAs(projectDirectory + "\\" + CustomBuilderName + ".csproj.user", Encoding.UTF8, vals);
            _tempConfig.SaveAs(projectDirectory + "\\bin\\Debug\\" + CustomBuilderName + ".builder", Encoding.UTF8, vals);
            _tempConfig.SaveAs(projectDirectory + "\\bin\\Release\\" + CustomBuilderName + "\\" + CustomBuilderName + ".builder", Encoding.UTF8, vals);
            _tempInfo.SaveAs(projectDirectory + "\\Properties\\AssemblyInfo.cs", Encoding.UTF8, vals);
            switch (SolutionType)
            {
            case CustomBuilderSolutionType.ExtentSection:
            case CustomBuilderSolutionType.ExtentTag:
            {
                _tempCode_ExtentTag.SaveAs(projectDirectory + "\\" + CustomBuilderName + ".cs", Encoding.UTF8, vals);
                break;
            }

            case CustomBuilderSolutionType.CustomPage:
            {
                _tempCode_CustomStyle.SaveAs(projectDirectory + "\\" + CustomBuilderName + ".cs", Encoding.UTF8, vals);
                break;
            }

            default:
            {
                _tempCode_Common.SaveAs(projectDirectory + "\\" + CustomBuilderName + ".cs", Encoding.UTF8, vals);
                break;
            }
            }
            File.Copy(AppDomain.CurrentDomain.BaseDirectory + "\\ADB.Factories.dll", projectDirectory + "\\ADB.Factories.dll");
        }