Ejemplo n.º 1
0
        public string FillTemplate(ConfigValuesFile values)
        {
            string result = _templateText;

            foreach (KeyValuePair <string, string> kvp in values)
            {
                result = result.Replace("%" + kvp.Key + "%", kvp.Value);
            }

            return(result);
        }
Ejemplo n.º 2
0
        public void RunTemplates(string outputDir)
        {
            ConfigValuesFile values = this.SetupValues();

            foreach (ConfigTemplate template in _templates)
            {
                string filledTemplate = template.FillTemplate(values);
                string fullOutPath    = Path.Combine(outputDir, Path.GetFileName(template.FileName.Replace(".tmpl", "")));

                File.WriteAllText(fullOutPath, filledTemplate, Encoding.ASCII);
            }
        }
Ejemplo n.º 3
0
        private ConfigValuesFile SetupValues()
        {
            ConfigValuesFile cv = new ConfigValuesFile(_valueFilePath);

            //also add values pushed to us
            foreach (KeyValuePair <string, string> val in _extraValues)
            {
                cv.Add(val.Key, val.Value);
            }

            //validate that there arent any {REQUIRE} values undefined
            cv.Validate();

            return(cv);
        }