Adding interface to PackagingService

This commit is contained in:
Morten Christensen
2014-01-08 13:37:51 +01:00
parent 525477f84f
commit 5bcd6a9982
4 changed files with 83 additions and 10 deletions

View File

@@ -0,0 +1,74 @@
using System.Collections.Generic;
using System.Xml.Linq;
using Umbraco.Core.Models;
namespace Umbraco.Core.Services
{
public interface IPackagingService : IService
{
/// <summary>
/// Imports and saves package xml as <see cref="IContent"/>
/// </summary>
/// <param name="element">Xml to import</param>
/// <param name="parentId">Optional parent Id for the content being imported</param>
/// <param name="userId">Optional Id of the user performing the import</param>
/// <returns>An enumrable list of generated content</returns>
IEnumerable<IContent> ImportContent(XElement element, int parentId = -1, int userId = 0);
/// <summary>
/// Imports and saves package xml as <see cref="IContentType"/>
/// </summary>
/// <param name="element">Xml to import</param>
/// <param name="userId">Optional id of the User performing the operation. Default is zero (admin).</param>
/// <returns>An enumrable list of generated ContentTypes</returns>
IEnumerable<IContentType> ImportContentTypes(XElement element, int userId = 0);
/// <summary>
/// Imports and saves package xml as <see cref="IContentType"/>
/// </summary>
/// <param name="element">Xml to import</param>
/// <param name="importStructure">Boolean indicating whether or not to import the </param>
/// <param name="userId">Optional id of the User performing the operation. Default is zero (admin).</param>
/// <returns>An enumrable list of generated ContentTypes</returns>
IEnumerable<IContentType> ImportContentTypes(XElement element, bool importStructure, int userId = 0);
/// <summary>
/// Imports and saves package xml as <see cref="IDataTypeDefinition"/>
/// </summary>
/// <param name="element">Xml to import</param>
/// <param name="userId"></param>
/// <returns>An enumrable list of generated DataTypeDefinitions</returns>
IEnumerable<IDataTypeDefinition> ImportDataTypeDefinitions(XElement element, int userId = 0);
/// <summary>
/// Imports and saves package xml as <see cref="ITemplate"/>
/// </summary>
/// <param name="element">Xml to import</param>
/// <param name="userId">Optional user id</param>
/// <returns>An enumrable list of generated Templates</returns>
IEnumerable<ITemplate> ImportTemplates(XElement element, int userId = 0);
/// <summary>
/// Exports an <see cref="IContentType"/> to xml as an <see cref="XElement"/>
/// </summary>
/// <param name="contentType">ContentType to export</param>
/// <returns><see cref="XElement"/> containing the xml representation of the ContentType item.</returns>
XElement Export(IContentType contentType);
/// <summary>
/// Exports an <see cref="IContent"/> item to xml as an <see cref="XElement"/>
/// </summary>
/// <param name="content">Content to export</param>
/// <param name="deep">Optional parameter indicating whether to include descendents</param>
/// <returns><see cref="XElement"/> containing the xml representation of the Content object</returns>
XElement Export(IContent content, bool deep = false);
/// <summary>
/// Exports an <see cref="IMedia"/> item to xml as an <see cref="XElement"/>
/// </summary>
/// <param name="media">Media to export</param>
/// <param name="deep">Optional parameter indicating whether to include descendents</param>
/// <returns><see cref="XElement"/> containing the xml representation of the Media object</returns>
XElement Export(IMedia media, bool deep = false);
}
}

View File

@@ -1,10 +1,8 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading;
using System.Xml.Linq;
using Umbraco.Core.Configuration;
using Umbraco.Core.IO;
@@ -22,7 +20,7 @@ namespace Umbraco.Core.Services
/// Represents the Packaging Service, which provides import/export functionality for the Core models of the API
/// using xml representation. This is primarily used by the Package functionality.
/// </summary>
public class PackagingService : IService
public class PackagingService : IPackagingService
{
private readonly IContentService _contentService;
private readonly IContentTypeService _contentTypeService;
@@ -106,7 +104,7 @@ namespace Umbraco.Core.Services
/// <param name="content">Content to export</param>
/// <param name="deep">Optional parameter indicating whether to include descendents</param>
/// <returns><see cref="XElement"/> containing the xml representation of the Content object</returns>
internal XElement Export(IContent content, bool deep = false)
public XElement Export(IContent content, bool deep = false)
{
//nodeName should match Casing.SafeAliasWithForcingCheck(content.ContentType.Alias);
var nodeName = UmbracoConfig.For.UmbracoSettings().Content.UseLegacyXmlSchema ? "node" : content.ContentType.Alias.ToSafeAliasWithForcingCheck();
@@ -937,7 +935,7 @@ namespace Umbraco.Core.Services
/// <param name="media">Media to export</param>
/// <param name="deep">Optional parameter indicating whether to include descendents</param>
/// <returns><see cref="XElement"/> containing the xml representation of the Media object</returns>
internal XElement Export(IMedia media, bool deep = false)
public XElement Export(IMedia media, bool deep = false)
{
//nodeName should match Casing.SafeAliasWithForcingCheck(content.ContentType.Alias);
var nodeName = UmbracoConfig.For.UmbracoSettings().Content.UseLegacyXmlSchema ? "node" : media.ContentType.Alias.ToSafeAliasWithForcingCheck();

View File

@@ -21,7 +21,7 @@ namespace Umbraco.Core.Services
private Lazy<IDataTypeService> _dataTypeService;
private Lazy<IFileService> _fileService;
private Lazy<ILocalizationService> _localizationService;
private Lazy<PackagingService> _packagingService;
private Lazy<IPackagingService> _packagingService;
private Lazy<ServerRegistrationService> _serverRegistrationService;
private Lazy<IEntityService> _entityService;
private Lazy<IRelationService> _relationService;
@@ -52,7 +52,7 @@ namespace Umbraco.Core.Services
IDataTypeService dataTypeService,
IFileService fileService,
ILocalizationService localizationService,
PackagingService packagingService,
IPackagingService packagingService,
IEntityService entityService,
IRelationService relationService,
ISectionService sectionService,
@@ -66,7 +66,7 @@ namespace Umbraco.Core.Services
_dataTypeService = new Lazy<IDataTypeService>(() => dataTypeService);
_fileService = new Lazy<IFileService>(() => fileService);
_localizationService = new Lazy<ILocalizationService>(() => localizationService);
_packagingService = new Lazy<PackagingService>(() => packagingService);
_packagingService = new Lazy<IPackagingService>(() => packagingService);
_entityService = new Lazy<IEntityService>(() => entityService);
_relationService = new Lazy<IRelationService>(() => relationService);
_sectionService = new Lazy<ISectionService>(() => sectionService);
@@ -129,7 +129,7 @@ namespace Umbraco.Core.Services
_localizationService = new Lazy<ILocalizationService>(() => new LocalizationService(provider, repositoryFactory.Value));
if (_packagingService == null)
_packagingService = new Lazy<PackagingService>(() => new PackagingService(_contentService.Value, _contentTypeService.Value, _mediaService.Value, _dataTypeService.Value, _fileService.Value, _localizationService.Value, repositoryFactory.Value, provider));
_packagingService = new Lazy<IPackagingService>(() => new PackagingService(_contentService.Value, _contentTypeService.Value, _mediaService.Value, _dataTypeService.Value, _fileService.Value, _localizationService.Value, repositoryFactory.Value, provider));
if (_entityService == null)
_entityService = new Lazy<IEntityService>(() => new EntityService(provider, repositoryFactory.Value, _contentService.Value, _contentTypeService.Value, _mediaService.Value, _dataTypeService.Value));
@@ -244,7 +244,7 @@ namespace Umbraco.Core.Services
/// <summary>
/// Gets the <see cref="PackagingService"/>
/// </summary>
public PackagingService PackagingService
public IPackagingService PackagingService
{
get { return _packagingService.Value; }
}

View File

@@ -983,6 +983,7 @@
<Compile Include="Services\IMembershipMemberService.cs" />
<Compile Include="Services\IMembershipUserService.cs" />
<Compile Include="Services\IMemberTypeService.cs" />
<Compile Include="Services\IPackagingService.cs" />
<Compile Include="Services\IRelationService.cs" />
<Compile Include="Services\ISectionService.cs" />
<Compile Include="Services\IService.cs" />