Exemplo 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);
        }
 private void Load()
 {
     foreach (var line in _repository.ReadAllLines(File.PreviousChallenges, true).Select(p => p.Split(",")))
     {
         Add(new ChallengeResult(line[0], line[1], line[2]));
     }
 }
        private void AddTranslation(string translationFile)
        {
            var lines = _repository.ReadAllLines(translationFile, false);

            if (lines.Length != Count)
            {
                Console.WriteLine($"Translation file '{translationFile}' has an invalid number of entries. Expected: {Count}.");
                return;
            }

            var languageName = translationFile.Replace("Translations.", "").Replace(".lang", "");

            for (var i = 0; i < lines.Length; i++)
            {
                var line     = lines[i];
                var building = _buildings[i];

                building.AddTranslation(languageName, line);
            }
        }