Пример #1
0
        public object Merge(string templatePath, IDaoTemplateHelper helper, string outputPath, NameValueCollection additionalArgs)
        {
            _logger.DebugEnter(MethodBase.GetCurrentMethod(), templatePath, helper, outputPath);

            if (helper == null)
            {
                throw new ApplicationException("null helper");
            }

            VelocityContext context = new VelocityContext();

            context.Put(helper.Name, helper);

            if (additionalArgs != null)
            {
                foreach (string key in additionalArgs.AllKeys)
                {
                    context.Put(key, additionalArgs[key]);
                }
            }

            Merge(templatePath, context, outputPath);

            _logger.Debug("Result: {0}", helper.GetResult());
            return(helper.GetResult());
        }
Пример #2
0
        /// <summary>
        /// Merges provided Velocity template with a Dao Helper into a specified file
        /// </summary>
        /// <param name="templatePath">Path to the output file</param>
        /// <param name="helper">Instance of the Dao Helper</param>
        /// <param name="outputPath">If the output file already exists it will be overritten</param>
        /// <returns>Instance of the input object in case its state was modified by the template</returns>
        public object Merge(string templatePath, IDaoTemplateHelper helper, string outputPath)
        {
            _logger.DebugEnter(MethodBase.GetCurrentMethod(), templatePath, helper, outputPath);

            if (helper == null)
            {
                throw new ApplicationException("null helper");
            }

            VelocityContext context = new VelocityContext();

            context.Put(helper.Name, helper);

            Merge(templatePath, context, outputPath);

            _logger.Debug("Result: {0}", helper.GetResult());
            return(helper.GetResult());
        }