Exemplo n.º 1
0
        public NewBoilerplateResult Process(NewBoilerplateContenxt ctx)
        {
            NewBoilerplateResult result = new NewBoilerplateResult();



            return(result);
        }
Exemplo n.º 2
0
        public static NewBoilerplateResult Process(NewOptions options)
        {
            NewBoilerplateResult result = null;
            //NewBoilerplateContenxt ctx = new NewBoilerplateContenxt();
            //ctx.Boilerplate = options.Boilerplate;

            var provider = Providers.FirstOrDefault(p => p.Name == options.Boilerplate);

            if (provider != null)
            {
                //ctx.BoilerplatPath = DbLoader.CombinePathWithAppDirectory(@"\Boilerplats\"+ ctx.Boilerplate);
                //ctx.ProjectName = options.Project;
                //ctx.ProjectOutputPath = DbLoader.CombinePathWithAppDirectory(@"\generate\" + ctx.ProjectName);

                //result = provider.Process(ctx);

                string config = DbLoader.CombinePathWithAppDirectory(@"Boilerplats\" + options.Boilerplate + @"\config.xml");
                NewBoilerplateManage.DoGen(config, options.Project, options.NameSpace, options.PrefixFilter, options.OnlyGenTable);


                string genDir = DbLoader.CombinePathWithAppDirectory(@"generate\" + options.Boilerplate);
                LogStatic("Starting copy resource to generate directory ......");
                LogStatic("Generate directory : " + genDir);

                string resourceDir = DbLoader.CombinePathWithAppDirectory(@"Boilerplats\" + options.Boilerplate + @"\resource");
                var    dirs        = Directory.GetDirectories(resourceDir, "*", SearchOption.TopDirectoryOnly);

                CurrentGenerateContext.ProjectName = options.Project;

                foreach (var dir in dirs)
                {
                    var    dirInfo     = new DirectoryInfo(dir);
                    var    dirname     = dirInfo.Name;// Path.GetDirectoryName(dir);
                    string realDirName = FormatSimpleTemplate(dirname);
                    string toDir       = Path.Combine(genDir, realDirName);
                    LogStatic("Copy directory resource " + dirname + " to " + toDir);

                    CopyDirectory(dir, toDir);
                    LogStatic("Finish copy directory.");
                }

                LogStatic("Finish copy resource to generate directory !");
            }
            else
            {
                LogStatic("Not find Boilerplate [" + options.Boilerplate + "] !", null, MessageType.Error);
            }

            return(result);
        }