/// <summary>The process template file.</summary>
        /// <param name="filename">The filename.</param>
        /// <param name="getValueForParameter">The get value for parameter.</param>
        /// <returns></returns>
        public TemplateResult ProcessTemplateFile(string filename, GetValueForParameter getValueForParameter)
        {
            Dictionary<string, object> items = new Dictionary<string, object>();
            string[] lines = File.ReadAllLines(filename);

            items[Extension] = InferExtensionFromFilename(filename, items);

            string text = PreProcessTemplate(lines, getValueForParameter, items);
            return ProcessTemplate(text, items);
        }
        /// <summary>The pre process template.</summary>
        /// <param name="lines">The lines.</param>
        /// <param name="getValueForParameter">The get value for parameter.</param>
        /// <param name="items">The items.</param>
        /// <returns>The pre process template.</returns>
        public string PreProcessTemplate(
            string[] lines,
            GetValueForParameter getValueForParameter,
            Dictionary <string, object> items)
        {
            int i = 0;

            for (; i < lines.Length; i++)
            {
                string line = lines[i];
                if (line.StartsWith("#@"))
                {
// process cmd
                    if (line.StartsWith("#@get ", StringComparison.CurrentCultureIgnoreCase))
                    {
                        string name = line.Substring("#@get ".Length);
                        string val  = getValueForParameter(name);
                        items.Add(name, val);
                    }
                    else if (line.StartsWith("#@set extension ", StringComparison.CurrentCultureIgnoreCase))
                    {
                        items[Extension] = line.Substring("#@set extension ".Length);
                    }
                    else if (line.StartsWith("#@import-plugin ", StringComparison.CurrentCultureIgnoreCase))
                    {
                        string pluginKeyName = line.Substring("#@import-plugin ".Length);
                        items[pluginKeyName.Replace(".", "_")] = _services.Resolve <IPlugIn>(pluginKeyName);
                    }
                }
                else
                {
                    break;
                }
            }

            string text = string.Join(Environment.NewLine, lines, i, lines.Length - i);

            return(text);
        }
        /// <summary>The process template file.</summary>
        /// <param name="filename">The filename.</param>
        /// <param name="getValueForParameter">The get value for parameter.</param>
        /// <returns></returns>
        public TemplateResult ProcessTemplateFile(string filename, GetValueForParameter getValueForParameter)
        {
            Dictionary<string, object> items = new Dictionary<string, object>();
            string[] lines = File.ReadAllLines(filename);

            items[Extension] = InferExtensionFromFilename(filename, items);

            string text = PreProcessTemplate(lines, getValueForParameter, items);
            return ProcessTemplate(text, items);
        }
        /// <summary>The pre process template.</summary>
        /// <param name="lines">The lines.</param>
        /// <param name="getValueForParameter">The get value for parameter.</param>
        /// <param name="items">The items.</param>
        /// <returns>The pre process template.</returns>
        public string PreProcessTemplate(
            string[] lines,
            GetValueForParameter getValueForParameter,
            Dictionary<string, object> items)
        {
            int i = 0;
            for (; i < lines.Length; i++)
            {
                string line = lines[i];
                if (line.StartsWith("#@"))
                {
                    // process cmd
                    if (line.StartsWith("#@get ", StringComparison.CurrentCultureIgnoreCase))
                    {
                        string name = line.Substring("#@get ".Length);
                        string val = getValueForParameter(name);
                        items.Add(name, val);
                    }
                    else if (line.StartsWith("#@set extension ", StringComparison.CurrentCultureIgnoreCase))
                    {
                        items[Extension] = line.Substring("#@set extension ".Length);
                    }
                    else if (line.StartsWith("#@import-plugin ", StringComparison.CurrentCultureIgnoreCase))
                    {
                        string pluginKeyName = line.Substring("#@import-plugin ".Length);
                        items[pluginKeyName.Replace(".", "_")] = _services.Resolve<IPlugIn>(pluginKeyName);
                    }
                }
                else
                {
                    break;
                }
            }

            string text = string.Join(Environment.NewLine, lines, i, lines.Length - i);

            return text;
        }