Пример #1
0
        static void Main(string[] args)
        {
            string a= "\"";
            //获取命令行参数
            CodeGenerator.MetadataModel.ArgsHelper pars = new CodeGenerator.MetadataModel.ArgsHelper(args);
            GlobalVariable par = new GlobalVariable();
            par.Creater = pars.Creator;
            par.Copyright = pars.CopyrightTeamName;
            string strFilter = SqlMetaData.SqlStandard.BuildFilter(pars);

            string ConfName = ConfigurationManager.AppSettings["ConfName"].ToString();
            Conf conf = ConfFactory.CurrentConf(ConfName);

            MetaDataFactory factory = new MetaDataFactory(conf, par);
            //获取元数据定义
            List<TableDef> tabs = factory.GetMetaData(strFilter);

            //判定
            foreach (TableDef tb in tabs)
            {
                factory.CreateAllFile(false,tb);
                System.Console.WriteLine("生成代码{0}成功;\n",tb.Name);
            }

            //输出文件
            foreach (TableDef tb in tabs)
            {
                //factory.CreateAllFile(false,tb);
            }
        }
Пример #2
0
        public void Parsetest()
        {
            string template = "@(Model.Table.Name + \".cs\")";
            GlobalVariable par = new GlobalVariable();
            TableDef tb =new TableDef();
            tb.Name = "abc";
            string strExpected = "abc.cs";
            string result = RazorHelper.Parse(template, par, tb,"asfs");

            Assert.AreEqual(strExpected, result);
        }
Пример #3
0
        public static string Parse(string template, GlobalVariable par, TableDef tab,string cacheName)
        {
            string result = "";

            //DynamicViewBag vb = new DynamicViewBag();
            //vb.GetDynamicMemberNames()

            TemplateServiceConfiguration config = new TemplateServiceConfiguration();
            config.BaseTemplateType = typeof(HtmlTemplateBase<>);
            TemplateService svc = new TemplateService(config);
            Razor.SetTemplateService(svc);

            result = Razor.Parse(template, new { GlobalVariable = par, Table = tab },cacheName);
            return result;
        }
Пример #4
0
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="conf"></param>
        /// <param name="par"></param>
        public MetaDataFactory(Conf conf, GlobalVariable par)
        {
            _CurrentConf = conf;
            _CurrentPar = par;

            //变化点:
            //读取模板信息到配置中
            string strCodeTemplateFileName = System.IO.Path.Combine(_CurrentConf.TemplateDir, _strTemplateCodeFileName);
            _CurrentConf.CodeTemplate = FileHelper.ReadTemplate(strCodeTemplateFileName);

            if (_CurrentConf.OutputOperationSplite)
            {
                strCodeTemplateFileName = System.IO.Path.Combine(_CurrentConf.TemplateDir, _strTemplateOperatorFileName);
                _CurrentConf.OperatorTemplate = FileHelper.ReadTemplate(strCodeTemplateFileName);
            }

            //par.ModelSpaceName = _CurrentConf.OutputCodeNameSpacePattern;
            //if(conf.OutputOperationSplite && string.IsNullOrEmpty(_CurrentConf.OutputOperationCodeNameSpacePattern))
            //{
            //    par.OperatorSpaceName = _CurrentConf.OutputCodeNameSpacePattern;
            //}
        }