Ejemplo n.º 1
0
        public async Task Run(string[] args)
        {
            _logger.LogInformation("Starting...");


            ProjectInfo projectInfo = ProjectParser(_settingOptions);

            string     entityPath = Path.Combine(_settingOptions.BaseDirectory, _settingOptions.EntityFilePath);
            EntityInfo entityInfo = EntityParse(entityPath, projectInfo, _settingOptions);

            var model = new
            {
                ProjectInfo = projectInfo,
                EntityInfo  = entityInfo,
                Option      = new CommandOption()
                {
                    CustomRepository = false,
                },
                SettingOptions = _settingOptions
            };

            #region 参考值

            /*
             *  -   ProjectInfo	{LinCms.Scaffolding.Entities.ProjectInfo}	LinCms.Scaffolding.Entities.ProjectInfo
             *      BaseDirectory	"D:/code/github/lin-cms-dotnetcore/src/LinCms.Core/"	string
             *      FullName	"LinCms"	string
             *      Name	"LinCms"	string
             *
             *  -   EntityInfo
             *      BaseType	"FullAduitEntity"	string
             *      Name	"Doc"	string
             *      NameCamelize	"doc"	string
             *      NamePluralized	"Docs"	string
             *      Namespace	"LinCms.v1.Docs"	string
             *      NamespaceLastPart	"Docs"	string
             *      PrimaryKey	"long"	string
             *      RelativeDirectory	"v1/Docs"	string
             *      RelativeNamespace	"v1.Docs"	string
             *
             *  -   SettingOptions	{LinCms.Scaffolding.SettingOptions}	LinCms.Scaffolding.SettingOptions
             *      Areas	"Base"	string
             *      AreasCamelize	"base"	string
             *      BaseDirectory	"D:/code/github/lin-cms-dotnetcore/src/LinCms.Core/"	string
             *      EntityFilePath	"Entities/Doc.cs"	string
             *      OutputDirectory	"D:/code/github/Outputs"	string
             *      ProjectName	"LinCms"	string
             *      TemplatePath	"./Templates"	string
             *
             */
            #endregion
            string          templatePath    = Path.Combine(Environment.CurrentDirectory, _settingOptions.TemplatePath);
            CodeScaffolding codeScaffolding = new CodeScaffolding(templatePath, _settingOptions.OutputDirectory);
            await codeScaffolding.GenerateAsync(model);

            _logger.LogInformation("Finished!");
        }
Ejemplo n.º 2
0
        static async Task Main(string[] args)
        {
            ServiceProvider provider       = GetProvider();
            SettingOptions  settingOptions = provider.GetService <IOptionsMonitor <SettingOptions> >().CurrentValue;
            ProjectInfo     projectInfo    = ProjectParser(settingOptions);


            string     entityPath = Path.Combine(settingOptions.BaseDirectory, settingOptions.EntityFilePath);
            EntityInfo entityInfo = EntityParse(entityPath, projectInfo, settingOptions);

            var model = new
            {
                ProjectInfo = projectInfo,
                EntityInfo  = entityInfo,
                Option      = new CommandOption()
                {
                    CustomRepository = false,
                },
                SettingOptions = settingOptions
            };

            /*
             * -   ProjectInfo	{LinCms.Scaffolding.Entities.ProjectInfo}	LinCms.Scaffolding.Entities.ProjectInfo
             *  BaseDirectory	"D:/code/github/lin-cms-dotnetcore/src/LinCms.Core/"	string
             *  FullName	"LinCms"	string
             *  Name	"LinCms"	string
             *
             * -   EntityInfo
             *  BaseType	"FullAduitEntity"	string
             *  Name	"Doc"	string
             *  NameCamelize	"doc"	string
             *  NamePluralized	"Docs"	string
             *  Namespace	"LinCms.v1.Docs"	string
             *  NamespaceLastPart	"Docs"	string
             *  PrimaryKey	"long"	string
             *  RelativeDirectory	"v1/Docs"	string
             *  RelativeNamespace	"v1.Docs"	string
             *
             * -   SettingOptions	{LinCms.Scaffolding.SettingOptions}	LinCms.Scaffolding.SettingOptions
             *  Areas	"Base"	string
             *  AreasCamelize	"base"	string
             *  BaseDirectory	"D:/code/github/lin-cms-dotnetcore/src/LinCms.Core/"	string
             *  EntityFilePath	"Entities/Doc.cs"	string
             *  OutputDirectory	"D:/code/github/Outputs"	string
             *  ProjectName	"LinCms"	string
             *  TemplatePath	"./Templates"	string
             *
             */
            string          templatePath    = Path.Combine(Environment.CurrentDirectory, settingOptions.TemplatePath);
            CodeScaffolding codeScaffolding = new CodeScaffolding(templatePath, settingOptions.OutputDirectory);
            await codeScaffolding.GenerateAsync(model);

            Console.WriteLine("EveryThings is Ok!");
        }