Example #1
0
        /// <summary>
        /// ����Դ�ļ�
        /// </summary>
        /// <param name="templdate">ģ������</param>
        /// <param name="container">ITable �� IView</param>
        public static void Generator(string templdate, IContainer container, string databaseName)
        {
            SetMappingType(container);
            PutValue("class", container);
            PutValue("now", DateTime.Now.ToString("yyyy-MM-dd"));
            PutValue("database", Util.SetPascalCase(databaseName));

            NVelocity.Template template = null;

            StringWriter stringWriter = new StringWriter();
            try
            {
                template = Velocity.GetTemplate(templdate, encoding);
                template.Merge(context, stringWriter);
            }
            catch (ParseErrorException pee)
            {
                throw new Exception("ģ������ʱ�����쳣", pee);
            }

            container.SetCode(stringWriter.ToString());
        }