From be2c72f8b418fb26f7d2900a1257cc7c269f35c5 Mon Sep 17 00:00:00 2001 From: Morten Christensen Date: Fri, 10 Jan 2014 16:05:19 +0100 Subject: [PATCH] Adding new methods to the IPackagingService interface --- .../Services/IPackagingService.cs | 58 +++++++++++++++++++ src/Umbraco.Core/Services/PackagingService.cs | 55 +++++++++++++++--- 2 files changed, 104 insertions(+), 9 deletions(-) diff --git a/src/Umbraco.Core/Services/IPackagingService.cs b/src/Umbraco.Core/Services/IPackagingService.cs index 9f318988d7..4056b27be7 100644 --- a/src/Umbraco.Core/Services/IPackagingService.cs +++ b/src/Umbraco.Core/Services/IPackagingService.cs @@ -44,6 +44,20 @@ namespace Umbraco.Core.Services /// An enumrable list of generated DataTypeDefinitions IEnumerable ImportDataTypeDefinitions(XElement element, int userId = 0, bool raiseEvents = true); + /// + /// Imports and saves the 'DictionaryItems' part of the package xml as a list of + /// + /// Xml to import + /// An enumerable list of dictionary items + IEnumerable ImportDictionaryItems(XElement dictionaryItemElementList); + + /// + /// Imports and saves the 'Languages' part of a package xml as a list of + /// + /// Xml to import + /// An enumerable list of generated languages + IEnumerable ImportLanguages(XElement languageElementList); + /// /// Imports and saves package xml as /// @@ -78,5 +92,49 @@ namespace Umbraco.Core.Services /// Optional parameter indicating whether or not to raise events /// containing the xml representation of the Media object XElement Export(IMedia media, bool deep = false, bool raiseEvents = true); + + /// + /// Exports a list of items to xml as an + /// + /// List of Languages to export + /// containing the xml representation of the Language object + XElement Export(IEnumerable languages); + + /// + /// Exports a single item to xml as an + /// + /// Language to export + /// containing the xml representation of the Language object + XElement Export(ILanguage language); + + /// + /// Exports a list of items to xml as an + /// + /// List of dictionary items to export + /// Optional boolean indicating whether or not to include children + /// containing the xml representation of the IDictionaryItem objects + XElement Export(IEnumerable dictionaryItem, bool includeChildren = true); + + /// + /// Exports a single item to xml as an + /// + /// Dictionary Item to export + /// Optional boolean indicating whether or not to include children + /// containing the xml representation of the IDictionaryItem object + XElement Export(IDictionaryItem dictionaryItem, bool includeChildren); + + /// + /// Exports a list of Data Types + /// + /// List of data types to export + /// containing the xml representation of the IDataTypeDefinition objects + XElement Export(IEnumerable dataTypeDefinitions); + + /// + /// Exports a single Data Type + /// + /// Data type to export + /// containing the xml representation of the IDataTypeDefinition object + XElement Export(IDataTypeDefinition dataTypeDefinition); } } \ No newline at end of file diff --git a/src/Umbraco.Core/Services/PackagingService.cs b/src/Umbraco.Core/Services/PackagingService.cs index ea8d838bf7..1b897a6aca 100644 --- a/src/Umbraco.Core/Services/PackagingService.cs +++ b/src/Umbraco.Core/Services/PackagingService.cs @@ -749,11 +749,11 @@ namespace Umbraco.Core.Services #region DataTypes /// - /// Export a list of data types + /// Exports a list of Data Types /// - /// - /// - internal XElement Export(IEnumerable dataTypeDefinitions) + /// List of data types to export + /// containing the xml representation of the IDataTypeDefinition objects + public XElement Export(IEnumerable dataTypeDefinitions) { var container = new XElement("DataTypes"); foreach (var d in dataTypeDefinitions) @@ -763,7 +763,12 @@ namespace Umbraco.Core.Services return container; } - internal XElement Export(IDataTypeDefinition dataTypeDefinition) + /// + /// Exports a single Data Type + /// + /// Data type to export + /// containing the xml representation of the IDataTypeDefinition object + public XElement Export(IDataTypeDefinition dataTypeDefinition) { var prevalues = new XElement("PreValues"); @@ -796,7 +801,7 @@ namespace Umbraco.Core.Services /// Imports and saves package xml as /// /// Xml to import - /// + /// Optional id of the user /// Optional parameter indicating whether or not to raise events /// An enumrable list of generated DataTypeDefinitions public IEnumerable ImportDataTypeDefinitions(XElement element, int userId = 0, bool raiseEvents = true) @@ -906,6 +911,12 @@ namespace Umbraco.Core.Services #region Dictionary Items + /// + /// Exports a list of items to xml as an + /// + /// List of dictionary items to export + /// Optional boolean indicating whether or not to include children + /// containing the xml representation of the IDictionaryItem objects public XElement Export(IEnumerable dictionaryItem, bool includeChildren = true) { var xml = new XElement("DictionaryItems"); @@ -916,6 +927,12 @@ namespace Umbraco.Core.Services return xml; } + /// + /// Exports a single item to xml as an + /// + /// Dictionary Item to export + /// Optional boolean indicating whether or not to include children + /// containing the xml representation of the IDictionaryItem object public XElement Export(IDictionaryItem dictionaryItem, bool includeChildren) { var xml = new XElement("DictionaryItem", new XAttribute("Key", dictionaryItem.ItemKey)); @@ -939,6 +956,11 @@ namespace Umbraco.Core.Services return xml; } + /// + /// Imports and saves the 'DictionaryItems' part of the package xml as a list of + /// + /// Xml to import + /// An enumerable list of dictionary items public IEnumerable ImportDictionaryItems(XElement dictionaryItemElementList) { var languages = _localizationService.GetAllLanguages().ToList(); @@ -1015,6 +1037,11 @@ namespace Umbraco.Core.Services #region Languages + /// + /// Exports a list of items to xml as an + /// + /// List of Languages to export + /// containing the xml representation of the ILanguage objects public XElement Export(IEnumerable languages) { var xml = new XElement("Languages"); @@ -1025,6 +1052,11 @@ namespace Umbraco.Core.Services return xml; } + /// + /// Exports a single item to xml as an + /// + /// Language to export + /// containing the xml representation of the ILanguage object public XElement Export(ILanguage language) { var xml = new XElement("Language", @@ -1034,6 +1066,11 @@ namespace Umbraco.Core.Services return xml; } + /// + /// Imports and saves the 'Languages' part of a package xml as a list of + /// + /// Xml to import + /// An enumerable list of generated languages public IEnumerable ImportLanguages(XElement languageElementList) { var list = new List(); @@ -1325,6 +1362,9 @@ namespace Umbraco.Core.Services #endregion + #region Stylesheets + #endregion + #region Event Handlers /// /// Occurs before Importing Content @@ -1396,8 +1436,5 @@ namespace Umbraco.Core.Services /// public static event TypedEventHandler> TemplateImported; #endregion - - #region Stylesheets - #endregion } } \ No newline at end of file