예제 #1
0
        public string PopulateTemplate(Arr <SimParameter> parameters)
        {
            RequireTrue(this.IsTmplType());
            RequireFile(PathToCodeFile);
            var template = File.ReadAllText(PathToCodeFile);

            var expectedParameterNames = SimConfig.SimInput.SimParameters.Map(p => p.Name);
            var fullyPopulated         = expectedParameterNames.ForAll(
                n => parameters.ContainsParameter(n)
                );

            RequireTrue(fullyPopulated);

            var pathToPopulated = Path.GetTempFileName();

            File.Move(pathToPopulated, pathToPopulated + ".R");
            pathToPopulated += ".R";

            var populated = SubstitutePlaceholders(template, parameters);

            File.WriteAllText(pathToPopulated, populated);

            return(pathToPopulated);
        }