Ejemplo n.º 1
0
        private string ApplyGeneratorsToTemplate(string templateFile, string generatorFile)
        {
            var templateString = _repository.ReadAllText(templateFile, true);
            var definitions    = _repository.ReadAllLines(generatorFile, false);

            foreach (var definition in definitions)
            {
                if (string.IsNullOrWhiteSpace(definition))
                {
                    continue;
                }

                var splitDefinitions = definition.Split(',');
                var token            = splitDefinitions[0];
                var arguments        = splitDefinitions.Skip(1).ToArray();
                if (_generators.ContainsKey(token))
                {
                    templateString = _generators[token].Apply(templateString, arguments);
                }
                else
                {
                    throw new InvalidOperationException($"No generator defined for token '{token}'.");
                }
            }

            return(templateString);
        }
Ejemplo n.º 2
0
 public GameMetadata Read()
 {
     return(JsonConvert.DeserializeObject <GameMetadata>(_repository.ReadAllText(File.Metadata, false)));
 }