private IEnumerable <IDictionaryItem> InstallDictionaryItems(XElement dictionaryItemsElement) { if (string.Equals(Constants.Packaging.DictionaryItemsNodeName, dictionaryItemsElement.Name.LocalName) == false) { throw new ArgumentException("Must be \"" + Constants.Packaging.DictionaryItemsNodeName + "\" as root", "dictionaryItemsElement"); } return(_packagingService.ImportDictionaryItems(dictionaryItemsElement)); }
private async Task Unpack(string name, string chauffeurFolder, bool includeLanguages) { var fileLocation = fileSystem.Path.Combine(chauffeurFolder, name + ".xml"); if (!fileSystem.File.Exists(fileLocation)) { await Out.WriteLineAsync(string.Format("The package '{0}' is not found in the Chauffeur folder", name)); return; } using (var stream = fileSystem.File.OpenRead(fileLocation)) { var xml = XDocument.Load(stream); IEnumerable <Umbraco.Core.Models.ILanguage> importedLangs = new List <Umbraco.Core.Models.ILanguage>(); if (includeLanguages) { var languageNode = xml.Root.Element("Languages"); if (languageNode == null) { await Out.WriteLineAsync(string.Format("No languages found in package '{0}'. Moving on", name)); } else { importedLangs = packagingService.ImportLanguages(languageNode); } } var dictionaryItemsNode = xml.Root.Element("DictionaryItems"); if (dictionaryItemsNode == null) { await Out.WriteLineAsync(string.Format("{0} languages were imported, but no dictionary items found in package '{0}'. Moving on", name)); return; } var importedKeys = packagingService.ImportDictionaryItems(dictionaryItemsNode); await Out.WriteLineAsync(string.Format("{0} languages and {1} dictionary items from '{2}'.", importedLangs.Count(), importedKeys.Count(), name)); } }
public IEnumerable <IDictionaryItem> ImportDictionaryItems(XElement dictionaryItemElementList, bool raiseEvents = true) { return(realPackagingService.ImportDictionaryItems(dictionaryItemElementList, raiseEvents)); }