Exemplo n.º 1
0
        public static string GenProgram()
        {
            string          ret = "";
            ProgramTemplate t   = new ProgramTemplate();

            t.Session             = new TextTemplatingSession();
            t.Session["ProjCode"] = projOption.ProjCode;
            t.Initialize();
            ret = t.TransformText();
            return(ret);
        }
Exemplo n.º 2
0
        public void GenerateDataServiceHostProject(DataServiceSolution solution, string outputFolder)
        {
            outputFolder = Path.Combine(outputFolder, $"{solution.NamespacePrefix}.{solution.Name}.DataService.Host");
            var setupFolder = Path.Combine(outputFolder, "Setup");

            ReplaceDirectories(setupFolder);

            var session = new Dictionary <string, object>();

            session.Add("DataServiceSolution", solution);

            HostProjectTemplate projectTemplate = new HostProjectTemplate();

            projectTemplate.Session = session;
            projectTemplate.Initialize();
            string content = projectTemplate.TransformText();

            File.WriteAllText(Path.Combine(outputFolder, $"{solution.NamespacePrefix}.{solution.Name}.DataService.Host.csproj"), content);

            ProgramTemplate programTemplate = new ProgramTemplate();

            programTemplate.Session = session;
            programTemplate.Initialize();
            content = programTemplate.TransformText();
            File.WriteAllText(Path.Combine(outputFolder, $"Program.cs"), content);

            HostConstantsTemplate constantsTemplate = new HostConstantsTemplate();

            constantsTemplate.Session = session;
            constantsTemplate.Initialize();
            content = constantsTemplate.TransformText();
            File.WriteAllText(Path.Combine(setupFolder, $"Constants.cs"), content);


            ConfigurationTemplate configurationTemplate = new ConfigurationTemplate();

            configurationTemplate.Session = session;
            configurationTemplate.Initialize();
            content = configurationTemplate.TransformText();
            File.WriteAllText(Path.Combine(setupFolder, $"Configuration.cs"), content);

            AvailableCulturesTemplate culturesTemplate = new AvailableCulturesTemplate();

            culturesTemplate.Session = session;
            culturesTemplate.Initialize();
            content = culturesTemplate.TransformText();
            File.WriteAllText(Path.Combine(setupFolder, $"AvailableCultures.cs"), content);
        }