/// <summary>
        /// Create the template output
        /// </summary>
        public virtual string TransformText()
        {
            this.Write("using BWF.Globalisation.Concrete;\r\nusing System.Collections.Generic;\r\n\r\nnamespace" +
                       " ");

            #line 11 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\Template.DataService.Host\Setup\AvailableCulturesTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(DataServiceSolution.GetNamespace()));

            #line default
            #line hidden
            this.Write(".");

            #line 11 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\Template.DataService.Host\Setup\AvailableCulturesTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(DataServiceSolution.Name));

            #line default
            #line hidden
            this.Write(@".DataService.Host
{
    public class AvailableCultures
    {
        public static List<string> LanguageCultures = new List<string> 
        { 
            ""en-GB"" 
        };

        public static List<FormattingCulture> FormattingCultures = new List<FormattingCulture>
        {
            new FormattingCulture (""en-GB"", new List<string>
            {
                ""dd/MM/yyyy HH:mm"",
                ""dd MMMM yyyy HH:mm:ss"",
                ""dd/MM/yyyy HH:mm:ss"",
                ""dd-MM-yyyy HH:mm:ss"",
                ""dd-MMM-yyyy HH:mm:ss"",
                ""dd MMM yyyy HH:mm:ss""
            },
            new List<string>
            {
                ""dd/MM/yyyy"",
                ""dd MMMM yyyy"",
                ""dd MMMM"",
                ""MMMM yyyy"",
                ""dd-MM-yyyy"",
                ""dd-MMM-yyyy"",
                ""dd MMM yyyy""
            })
        };
    }
}
");
            return(this.GenerationEnvironment.ToString());
        }
Beispiel #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);
        }
Beispiel #3
0
        /// <summary>
        /// Create the template output
        /// </summary>
        public virtual string TransformText()
        {
            this.Write("namespace ");

            #line 8 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\Template.DataService.Host\Setup\ConstantsTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(DataServiceSolution.GetNamespace()));

            #line default
            #line hidden
            this.Write(".");

            #line 8 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\Template.DataService.Host\Setup\ConstantsTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(DataServiceSolution.Name));

            #line default
            #line hidden
            this.Write(".Domain\r\n{\r\n    public class ");

            #line 10 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\Template.DataService.Host\Setup\ConstantsTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(DataServiceSolution.Name));

            #line default
            #line hidden
            this.Write("HostConstants\r\n    {\r\n        public const string ServiceName = \"");

            #line 12 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\Template.DataService.Host\Setup\ConstantsTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(DataServiceSolution.ServiceName));

            #line default
            #line hidden
            this.Write("\";\r\n        public const string ServiceDisplayName = \"");

            #line 13 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\Template.DataService.Host\Setup\ConstantsTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(DataServiceSolution.ServiceDisplayName));

            #line default
            #line hidden
            this.Write("\";\r\n        public const string ServiceDescription = \"");

            #line 14 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\Template.DataService.Host\Setup\ConstantsTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(DataServiceSolution.ServiceDescription));

            #line default
            #line hidden
            this.Write("\";\r\n    }\r\n}");
            return(this.GenerationEnvironment.ToString());
        }
Beispiel #4
0
        public string GenerateAllAndZip(DataServiceSolution solution, string outputFolder)
        {
            var solutionFolder = Path.Combine(outputFolder, $"{solution.NamespacePrefix}.{solution.Name}");
            var zipFileName    = Path.Combine(outputFolder, $"{solution.NamespacePrefix}.{solution.Name}.zip");

            if (File.Exists(zipFileName))
            {
                File.Delete(zipFileName);
            }

            GenerateSolution(solution, solutionFolder);
            GenerateScripts(solution, solutionFolder);

            ZipFile.CreateFromDirectory(solutionFolder, zipFileName);

            return(zipFileName);
        }
        /// <summary>
        /// Create the template output
        /// </summary>
        public virtual string TransformText()
        {
            this.Write("using System;\r\nusing System.Configuration;\r\n\r\nnamespace ");

            #line 11 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\Template.DataService.Host\Setup\ConfigurationTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(DataServiceSolution.GetNamespace()));

            #line default
            #line hidden
            this.Write(".");

            #line 11 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\Template.DataService.Host\Setup\ConfigurationTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(DataServiceSolution.Name));

            #line default
            #line hidden
            this.Write(".Domain\r\n{\r\n    public class ");

            #line 13 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\Template.DataService.Host\Setup\ConfigurationTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(DataServiceSolution.Name));

            #line default
            #line hidden
            this.Write("HostConfiguration\r\n    {\r\n        public string HostUrl { get; set; }\r\n\r\n        " +
                       "public static ");

            #line 17 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\Template.DataService.Host\Setup\ConfigurationTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(DataServiceSolution.Name));

            #line default
            #line hidden
            this.Write("HostConfiguration Read()\r\n        {\r\n            return new ");

            #line 19 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\Template.DataService.Host\Setup\ConfigurationTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(DataServiceSolution.Name));

            #line default
            #line hidden
            this.Write("HostConfiguration {\r\n                HostUrl = ConfigurationManager.AppSettings[\"" +
                       "HostUrl\"]\r\n            };\r\n        }\r\n    }\r\n}\r\n");
            return(this.GenerationEnvironment.ToString());
        }
Beispiel #6
0
        public void GenerateScripts(DataServiceSolution solution, string outputFolder)
        {
            outputFolder = Path.Combine(outputFolder, $"DatabaseScripts");
            var sqlScriptsBaseFolder    = Path.Combine(outputFolder, "SqlServer");
            var oracleScriptsBaseFolder = Path.Combine(outputFolder, "Oracle");

            ReplaceDirectories(outputFolder, sqlScriptsBaseFolder, oracleScriptsBaseFolder);

            foreach (var dataService in solution.DataServices)
            {
                var session = new Dictionary <string, object>();
                session.Add("DomainDataService", dataService);

                if (!(dataService.Schemas is null))
                {
                    var sqlScriptsFolder    = Path.Combine(sqlScriptsBaseFolder, dataService.Name);
                    var oracleScriptsFolder = Path.Combine(oracleScriptsBaseFolder, dataService.Name);

                    ReplaceDirectories(sqlScriptsFolder, oracleScriptsFolder);

                    foreach (var domainSchema in dataService.Schemas)
                    {
                        session["CurrentSchema"] = domainSchema;

                        SqlServerScriptTemplate sqlScriptTemplate = new SqlServerScriptTemplate();
                        sqlScriptTemplate.Session = session;
                        sqlScriptTemplate.Initialize();
                        var content = sqlScriptTemplate.TransformText();
                        File.WriteAllText(Path.Combine(sqlScriptsFolder, $"{domainSchema.SchemaName.ToLower()}_1_0_0_1.sql"), content);

                        OracleScriptTemplate oracleScriptTemplate = new OracleScriptTemplate();
                        oracleScriptTemplate.Session = session;
                        oracleScriptTemplate.Initialize();
                        content = oracleScriptTemplate.TransformText();
                        File.WriteAllText(Path.Combine(oracleScriptsFolder, $"{domainSchema.SchemaName.ToLower()}_1_0_0_1.sql"), content);
                    }
                }
            }
        }
Beispiel #7
0
        public void GenerateSolution(DataServiceSolution solution, string outputFolder)
        {
            ReplaceDirectories(outputFolder);

            foreach (var dataService in solution.DataServices)
            {
                GenerateDomainProject(dataService, outputFolder);
                GenerateDataServiceProject(dataService, outputFolder);
            }
            GenerateDataServiceHostProject(solution, outputFolder);

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

            session.Add("DataServiceSolution", solution);

            SolutionTemplate solutionTemplate = new SolutionTemplate();

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

            File.WriteAllText(Path.Combine(outputFolder, $"{solution.NamespacePrefix}.{solution.Name}.sln"), content);
        }
Beispiel #8
0
        /// <summary>
        /// Create the template output
        /// </summary>
        public virtual string TransformText()
        {
            #line 8 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
            var rootGuid = Guid.NewGuid();

            #line default
            #line hidden

            #line 9 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
            var namespacePrefix = DataServiceSolution.GetNamespace();

            #line default
            #line hidden

            #line 10 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
            var domainGuids = new Dictionary <string, Guid>();

            #line default
            #line hidden

            #line 11 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
            var dataServiceGuids = new Dictionary <string, Guid>();

            #line default
            #line hidden

            #line 12 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
            var hostGuids = new Dictionary <string, Guid>();

            #line default
            #line hidden
            this.Write("Microsoft Visual Studio Solution File, Format Version 12.00\r\n# Visual Studio 15\r\n" +
                       "VisualStudioVersion = 15.0.28307.421\r\nMinimumVisualStudioVersion = 10.0.40219.1\r" +
                       "\n");

            #line 17 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
            foreach (var dataService in DataServiceSolution.DataServices)
            {
            #line default
            #line hidden

            #line 18 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
                domainGuids.Add(dataService.Name, Guid.NewGuid());

            #line default
            #line hidden

            #line 19 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
                dataServiceGuids.Add(dataService.Name, Guid.NewGuid());

            #line default
            #line hidden

            #line 20 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
                hostGuids.Add(dataService.Name, Guid.NewGuid());

            #line default
            #line hidden
                this.Write("Project(\"{");

            #line 21 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(rootGuid));

            #line default
            #line hidden
                this.Write("}\") = \"");

            #line 21 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(namespacePrefix));

            #line default
            #line hidden
                this.Write(".");

            #line 21 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(dataService.Name));

            #line default
            #line hidden
                this.Write(".Domain\", \"");

            #line 21 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(namespacePrefix));

            #line default
            #line hidden
                this.Write(".");

            #line 21 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(dataService.Name));

            #line default
            #line hidden
                this.Write(".Domain\\");

            #line 21 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(namespacePrefix));

            #line default
            #line hidden
                this.Write(".");

            #line 21 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(dataService.Name));

            #line default
            #line hidden
                this.Write(".Domain.csproj\", \"{");

            #line 21 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(domainGuids[dataService.Name]));

            #line default
            #line hidden
                this.Write("}\"\r\nEndProject\r\nProject(\"{");

            #line 23 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(rootGuid));

            #line default
            #line hidden
                this.Write("}\") = \"");

            #line 23 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(namespacePrefix));

            #line default
            #line hidden
                this.Write(".");

            #line 23 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(dataService.Name));

            #line default
            #line hidden
                this.Write(".DataService\", \"");

            #line 23 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(namespacePrefix));

            #line default
            #line hidden
                this.Write(".");

            #line 23 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(dataService.Name));

            #line default
            #line hidden
                this.Write(".DataService\\");

            #line 23 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(namespacePrefix));

            #line default
            #line hidden
                this.Write(".");

            #line 23 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(dataService.Name));

            #line default
            #line hidden
                this.Write(".DataService.csproj\", \"{");

            #line 23 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(dataServiceGuids[dataService.Name]));

            #line default
            #line hidden
                this.Write("}\"\r\nEndProject\r\nProject(\"{");

            #line 25 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(rootGuid));

            #line default
            #line hidden
                this.Write("}\") = \"");

            #line 25 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(namespacePrefix));

            #line default
            #line hidden
                this.Write(".");

            #line 25 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(dataService.Name));

            #line default
            #line hidden
                this.Write(".DataService.Host\", \"");

            #line 25 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(namespacePrefix));

            #line default
            #line hidden
                this.Write(".");

            #line 25 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(dataService.Name));

            #line default
            #line hidden
                this.Write(".DataService.Host\\");

            #line 25 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(namespacePrefix));

            #line default
            #line hidden
                this.Write(".");

            #line 25 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(dataService.Name));

            #line default
            #line hidden
                this.Write(".DataService.Host.csproj\", \"{");

            #line 25 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(hostGuids[dataService.Name]));

            #line default
            #line hidden
                this.Write("}\"\r\nEndProject\r\n");

            #line 27 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
            }

            #line default
            #line hidden
            this.Write("Global\r\n\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\r\n\t\tDebug|Any" +
                       " CPU = Debug|Any CPU\r\n\t\tRelease|Any CPU = Release|Any CPU\r\n\tEndGlobalSection\r\n\tG" +
                       "lobalSection(ProjectConfigurationPlatforms) = postSolution\r\n");

            #line 34 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
            foreach (var dataService in DataServiceSolution.DataServices)
            {
            #line default
            #line hidden
                this.Write("\t\t{");

            #line 35 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(domainGuids[dataService.Name]));

            #line default
            #line hidden
                this.Write("}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r\n\t\t{");

            #line 36 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(domainGuids[dataService.Name]));

            #line default
            #line hidden
                this.Write("}.Debug|Any CPU.Build.0 = Debug|Any CPU\r\n\t\t{");

            #line 37 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(domainGuids[dataService.Name]));

            #line default
            #line hidden
                this.Write("}.Release|Any CPU.ActiveCfg = Release|Any CPU\r\n\t\t{");

            #line 38 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(domainGuids[dataService.Name]));

            #line default
            #line hidden
                this.Write("}.Release|Any CPU.Build.0 = Release|Any CPU\r\n\t\t{");

            #line 39 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(dataServiceGuids[dataService.Name]));

            #line default
            #line hidden
                this.Write("}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r\n\t\t{");

            #line 40 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(dataServiceGuids[dataService.Name]));

            #line default
            #line hidden
                this.Write("}.Debug|Any CPU.Build.0 = Debug|Any CPU\r\n\t\t{");

            #line 41 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(dataServiceGuids[dataService.Name]));

            #line default
            #line hidden
                this.Write("}.Release|Any CPU.ActiveCfg = Release|Any CPU\r\n\t\t{");

            #line 42 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(dataServiceGuids[dataService.Name]));

            #line default
            #line hidden
                this.Write("}.Release|Any CPU.Build.0 = Release|Any CPU\r\n\t\t{");

            #line 43 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(hostGuids[dataService.Name]));

            #line default
            #line hidden
                this.Write("}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r\n\t\t{");

            #line 44 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(hostGuids[dataService.Name]));

            #line default
            #line hidden
                this.Write("}.Debug|Any CPU.Build.0 = Debug|Any CPU\r\n\t\t{");

            #line 45 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(hostGuids[dataService.Name]));

            #line default
            #line hidden
                this.Write("}.Release|Any CPU.ActiveCfg = Release|Any CPU\r\n\t\t{");

            #line 46 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(hostGuids[dataService.Name]));

            #line default
            #line hidden
                this.Write("}.Release|Any CPU.Build.0 = Release|Any CPU\r\n");

            #line 47 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
            }

            #line default
            #line hidden
            this.Write("\tEndGlobalSection\r\n\tGlobalSection(SolutionProperties) = preSolution\r\n\t\tHideSoluti" +
                       "onNode = FALSE\r\n\tEndGlobalSection\r\n\tGlobalSection(ExtensibilityGlobals) = postSo" +
                       "lution\r\n\t\tSolutionGuid = {");

            #line 53 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\SolutionTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(Guid.NewGuid()));

            #line default
            #line hidden
            this.Write("}\r\n\tEndGlobalSection\r\nEndGlobal\r\n");
            return(this.GenerationEnvironment.ToString());
        }
Beispiel #9
0
        /// <summary>
        /// Create the template output
        /// </summary>
        public virtual string TransformText()
        {
            this.Write("using BWF.DataServices.Nancy.Interfaces;\r\nusing BWF.DataServices.StartUp.Concrete" +
                       ";\r\nusing BWF.Globalisation.Concrete;\r\nusing BWF.Globalisation.Interfaces;\r\nusing" +
                       " log4net.Config;\r\nusing ");

            #line 13 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\Template.DataService.Host\ProgramTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(DataServiceSolution.GetNamespace()));

            #line default
            #line hidden
            this.Write(".");

            #line 13 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\Template.DataService.Host\ProgramTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(DataServiceSolution.Name));

            #line default
            #line hidden
            this.Write(".Domain;\r\n\r\nnamespace ");

            #line 15 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\Template.DataService.Host\ProgramTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(DataServiceSolution.GetNamespace()));

            #line default
            #line hidden
            this.Write(".");

            #line 15 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\Template.DataService.Host\ProgramTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(DataServiceSolution.Name));

            #line default
            #line hidden
            this.Write(".DataService.Host\r\n{\r\n    class Program\r\n    {\r\n        static void Main(string[]" +
                       " args)\r\n        {\r\n            XmlConfigurator.Configure();\r\n\r\n            var c" +
                       "onfig = ");

            #line 23 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\Template.DataService.Host\ProgramTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(DataServiceSolution.Name));

            #line default
            #line hidden
            this.Write(@"HostConfiguration.Read();

            IResourceQuerier resourceQuerier = new ResourceQuerier(typeof(BWF.Globalisation.Resources).Assembly);
            var globalisationProvider = new GlobalisationProvider(resourceQuerier, AvailableCultures.LanguageCultures, AvailableCultures.FormattingCultures);

            IDataServiceHostSettings hostSettings =
                new DataServiceHostSettings(
                    ");

            #line 30 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\Template.DataService.Host\ProgramTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(DataServiceSolution.Name));

            #line default
            #line hidden
            this.Write("HostConstants.ServiceName,\r\n                    ");

            #line 31 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\Template.DataService.Host\ProgramTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(DataServiceSolution.Name));

            #line default
            #line hidden
            this.Write("HostConstants.ServiceDisplayName,\r\n                    ");

            #line 32 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\Template.DataService.Host\ProgramTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(DataServiceSolution.Name));

            #line default
            #line hidden
            this.Write("HostConstants.ServiceDescription,\r\n                    config.HostUrl,\r\n         " +
                       "           null,\r\n                    globalisationProvider);\r\n\r\n            var" +
                       " host = new DataServiceHost(hostSettings);\r\n            host.Start();\r\n        }" +
                       "\r\n    }\r\n}\r\n");
            return(this.GenerationEnvironment.ToString());
        }
        /// <summary>
        /// Create the template output
        /// </summary>
        public virtual string TransformText()
        {
            #line 8 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\Template.DataService.Host\HostProjectTemplate.tt"
            var namespacePrefix = DataServiceSolution.GetNamespace();

            #line default
            #line hidden
            this.Write(@"<Project Sdk=""Microsoft.NET.Sdk"">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net461</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include=""combined-bwf-dataservice-host"" Version=""2046.3.46"" />
  </ItemGroup>

  <ItemGroup>
");

            #line 21 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\Template.DataService.Host\HostProjectTemplate.tt"
            foreach (var dataService in DataServiceSolution.DataServices)
            {
            #line default
            #line hidden
                this.Write("    <ProjectReference Include=\"..\\");

            #line 22 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\Template.DataService.Host\HostProjectTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(namespacePrefix));

            #line default
            #line hidden
                this.Write(".");

            #line 22 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\Template.DataService.Host\HostProjectTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(dataService.Name));

            #line default
            #line hidden
                this.Write(".Domain\\");

            #line 22 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\Template.DataService.Host\HostProjectTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(namespacePrefix));

            #line default
            #line hidden
                this.Write(".");

            #line 22 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\Template.DataService.Host\HostProjectTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(dataService.Name));

            #line default
            #line hidden
                this.Write(".Domain.csproj\" />\r\n\t<ProjectReference Include=\"..\\");

            #line 23 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\Template.DataService.Host\HostProjectTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(namespacePrefix));

            #line default
            #line hidden
                this.Write(".");

            #line 23 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\Template.DataService.Host\HostProjectTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(dataService.Name));

            #line default
            #line hidden
                this.Write(".DataService\\");

            #line 23 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\Template.DataService.Host\HostProjectTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(namespacePrefix));

            #line default
            #line hidden
                this.Write(".");

            #line 23 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\Template.DataService.Host\HostProjectTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(dataService.Name));

            #line default
            #line hidden
                this.Write(".DataService.csproj\" />\r\n");

            #line 24 "C:\git\stuff\DataServiceDesigner\DataServiceDesigner.Templating\Templates\Template.DataService.Host\HostProjectTemplate.tt"
            }

            #line default
            #line hidden
            this.Write("  </ItemGroup>\r\n\r\n</Project>\r\n");
            return(this.GenerationEnvironment.ToString());
        }
Beispiel #11
0
        public void MyTestMethod()
        {
            TemplateGenerator generator   = new TemplateGenerator();
            DomainDataService dataService = new DomainDataService();

            dataService.Connection = new DataServiceConnection()
            {
                InitialCatalog = "TestDB"
            };
            dataService.Name    = "Test";
            dataService.Schemas = new List <DomainSchema>()
            {
                new DomainSchema()
                {
                    SchemaName = "schema1",
                    IsDefault  = true,
                    Objects    = new List <DomainObject> {
                        new DomainObject()
                        {
                            TableName   = "table1",
                            ObjectName  = "Object1",
                            DisplayName = "Object 1",
                            Properties  = new List <DomainObjectProperty>()
                            {
                                new DomainObjectProperty()
                                {
                                    PropertyName = "Property1",
                                    ColumnName   = "prop1",
                                    PropertyType = PropertyType.Int64
                                },
                                new DomainObjectProperty()
                                {
                                    IsPartOfKey  = true,
                                    PropertyName = "Property2",
                                    ColumnName   = "prop2",
                                    PropertyType = PropertyType.String
                                },
                                new DomainObjectProperty()
                                {
                                    PropertyName = "Property3",
                                    ColumnName   = "prop3",
                                    PropertyType = PropertyType.DateTime
                                },
                                new DomainObjectProperty()
                                {
                                    PropertyName = "property4",
                                    ColumnName   = "prop4",
                                    PropertyType = PropertyType.Boolean
                                },
                                new DomainObjectProperty()
                                {
                                    PropertyName = "Property5",
                                    ColumnName   = "prop5",
                                    PropertyType = PropertyType.Decimal
                                }
                            }
                        },
                        new DomainObject()
                        {
                            TableName   = "table2",
                            ObjectName  = "Object2",
                            DisplayName = "Object 2",
                            Properties  = new List <DomainObjectProperty>()
                            {
                                new DomainObjectProperty()
                                {
                                    PropertyName = "Id",
                                    PropertyType = PropertyType.Int64,
                                    IsPartOfKey  = true
                                },
                                new DomainObjectProperty()
                                {
                                    PropertyName = "Property2",
                                    PropertyType = PropertyType.String,
                                    Length       = 64
                                },
                                new DomainObjectProperty()
                                {
                                    PropertyName = "Property2",
                                    PropertyType = PropertyType.String,
                                    IsNullable   = true,
                                    Length       = 64
                                }
                            }
                        }
                    }
                }
            };

            DataServiceSolution solution = new DataServiceSolution()
            {
                NamespacePrefix    = "Prefix",
                ServiceName        = "Test.Service",
                ServiceDisplayName = "Test Service",
                ServiceDescription = "Test Service",
                CompanyName        = "Test Co",
                DataServices       = new List <DomainDataService> {
                    dataService
                }
            };

            dataService.Solution = solution;

            var outputPath = Path.Combine(Environment.CurrentDirectory, "Test");

            generator.GenerateAllAndZip(solution, outputPath);
        }
Beispiel #12
0
 public static string GetNamespace(this DataServiceSolution solution)
 {
     return(string.IsNullOrEmpty(solution.NamespacePrefix) ? Defaults.NamespacePrefix : solution.NamespacePrefix);
 }