internal void GenerateModels() { // Create directory if it doesn't exist if (!Directory.Exists(_config.DictionaryDirectory)) { Directory.CreateDirectory(_config.DictionaryDirectory); } // Delete all generated.cs files List <string> generatedFiles = Directory.GetFiles(_config.DictionaryDirectory, "*.generated.cs").ToList(); foreach (string file in generatedFiles) { File.Delete(file); } // Get the models from Umbraco DictionaryModel[] models = _umbracoService.GetDictionaryModels(); if (_config.GenerateFilePerDictionaryItem) { // Generate a file per model foreach (DictionaryModel model in models) { GenerateModels(model.GetItemKey(), model); } } else { // Generate a file containing all models GenerateModels(_config.DictionaryItemsPartialClassName, models); } }
/// <summary> /// Get all dictionary items for Vue app formatted as a tree in the shape that vue-I18n likes. /// </summary> /// <returns></returns> private dynamic GetAllItems(params string[] prefixes) { DictionaryModelWrapper[] dictionaryModels = _umbracoService.GetDictionaryModels(item => prefixes == null || !prefixes.Any() || prefixes.Any(prefix => item.ItemKey.Equals(prefix, StringComparison.InvariantCultureIgnoreCase) || item.ItemKey.StartsWith(prefix + ".", StringComparison.InvariantCultureIgnoreCase))) .OrderBy(item => item.GetItemKey()) .Cast <DictionaryModelWrapper>() .ToArray(); return(GenerateVueI18N(dictionaryModels, null)); }