diff --git a/src/Umbraco.Core/Models/CultureImpact.cs b/src/Umbraco.Abstractions/Models/CultureImpact.cs
similarity index 99%
rename from src/Umbraco.Core/Models/CultureImpact.cs
rename to src/Umbraco.Abstractions/Models/CultureImpact.cs
index ca18985941..eeb7fa82a3 100644
--- a/src/Umbraco.Core/Models/CultureImpact.cs
+++ b/src/Umbraco.Abstractions/Models/CultureImpact.cs
@@ -10,7 +10,7 @@ namespace Umbraco.Core.Models
/// A set of cultures can be either all cultures (including the invariant culture), or
/// the invariant culture, or a specific culture.
///
- internal class CultureImpact
+ public sealed class CultureImpact
{
///
/// Utility method to return the culture used for invariant property errors based on what cultures are being actively saved,
diff --git a/src/Umbraco.Core/Persistence/Querying/ValuePropertyMatchType.cs b/src/Umbraco.Abstractions/Persistence/Querying/ValuePropertyMatchType.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/Querying/ValuePropertyMatchType.cs
rename to src/Umbraco.Abstractions/Persistence/Querying/ValuePropertyMatchType.cs
diff --git a/src/Umbraco.Core/Services/IMemberService.cs b/src/Umbraco.Abstractions/Services/IMemberService.cs
similarity index 98%
rename from src/Umbraco.Core/Services/IMemberService.cs
rename to src/Umbraco.Abstractions/Services/IMemberService.cs
index ee0e2ef5ed..6f3979f101 100644
--- a/src/Umbraco.Core/Services/IMemberService.cs
+++ b/src/Umbraco.Abstractions/Services/IMemberService.cs
@@ -1,10 +1,6 @@
using System;
using System.Collections.Generic;
-using System.ComponentModel;
-using System.Net.Http;
using Umbraco.Core.Models;
-using Umbraco.Core.Models.Membership;
-using Umbraco.Core.Persistence.DatabaseModelDefinitions;
using Umbraco.Core.Persistence.Querying;
namespace Umbraco.Core.Services
diff --git a/src/Umbraco.Abstractions/Services/IMembershipMemberService.cs b/src/Umbraco.Abstractions/Services/IMembershipMemberService.cs
index a224dfc967..448b0c761a 100644
--- a/src/Umbraco.Abstractions/Services/IMembershipMemberService.cs
+++ b/src/Umbraco.Abstractions/Services/IMembershipMemberService.cs
@@ -1,11 +1,28 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
+using System.Collections.Generic;
+using Umbraco.Core.Models;
using Umbraco.Core.Models.Membership;
using Umbraco.Core.Persistence.Querying;
namespace Umbraco.Core.Services
{
+ ///
+ /// Defines part of the MemberService, which is specific to methods used by the membership provider.
+ ///
+ ///
+ /// Idea is to have this as an isolated interface so that it can be easily 'replaced' in the membership provider implementation.
+ ///
+ public interface IMembershipMemberService : IMembershipMemberService, IMembershipRoleService
+ {
+ ///
+ /// Creates and persists a new Member
+ ///
+ /// Username of the Member to create
+ /// Email of the Member to create
+ /// which the Member should be based on
+ ///
+ IMember CreateMemberWithIdentity(string username, string email, IMemberType memberType);
+ }
+
///
/// Defines part of the UserService/MemberService, which is specific to methods used by the membership provider.
/// The generic type is restricted to . The implementation of this interface uses
diff --git a/src/Umbraco.Abstractions/Services/IPropertyValidationService.cs b/src/Umbraco.Abstractions/Services/IPropertyValidationService.cs
new file mode 100644
index 0000000000..399bdd64d2
--- /dev/null
+++ b/src/Umbraco.Abstractions/Services/IPropertyValidationService.cs
@@ -0,0 +1,10 @@
+using Umbraco.Core.Models;
+
+namespace Umbraco.Core.Services
+{
+ public interface IPropertyValidationService
+ {
+ bool IsPropertyDataValid(IContent content, out IProperty[] invalidProperties, CultureImpact impact);
+ bool IsPropertyValid(IProperty property, string culture = "*", string segment = "*");
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Services/PropertyValidationService.cs b/src/Umbraco.Abstractions/Services/PropertyValidationService.cs
similarity index 92%
rename from src/Umbraco.Core/Services/PropertyValidationService.cs
rename to src/Umbraco.Abstractions/Services/PropertyValidationService.cs
index 1704d52206..bd9e3190b7 100644
--- a/src/Umbraco.Core/Services/PropertyValidationService.cs
+++ b/src/Umbraco.Abstractions/Services/PropertyValidationService.cs
@@ -1,17 +1,10 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Umbraco.Core.Collections;
-using Umbraco.Core.Composing;
+using System.Linq;
using Umbraco.Core.Models;
using Umbraco.Core.PropertyEditors;
namespace Umbraco.Core.Services
{
- //TODO: We should make this an interface and inject it into the ContentService
- internal class PropertyValidationService
+ internal class PropertyValidationService : IPropertyValidationService
{
private readonly PropertyEditorCollection _propertyEditors;
private readonly IDataTypeService _dataTypeService;
@@ -22,12 +15,6 @@ namespace Umbraco.Core.Services
_dataTypeService = dataTypeService;
}
- //TODO: Remove this method in favor of the overload specifying all dependencies
- public PropertyValidationService()
- : this(Current.PropertyEditors, Current.Services.DataTypeService)
- {
- }
-
///
/// Validates the content item's properties pass validation rules
///
diff --git a/src/Umbraco.Core/Services/ServiceContext.cs b/src/Umbraco.Abstractions/Services/ServiceContext.cs
similarity index 100%
rename from src/Umbraco.Core/Services/ServiceContext.cs
rename to src/Umbraco.Abstractions/Services/ServiceContext.cs
diff --git a/src/Umbraco.Core/Services/IMembershipMemberService.cs b/src/Umbraco.Core/Services/IMembershipMemberService.cs
deleted file mode 100644
index 4ecbaa5338..0000000000
--- a/src/Umbraco.Core/Services/IMembershipMemberService.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using System.Collections.Generic;
-using Umbraco.Core.Models;
-using Umbraco.Core.Models.Membership;
-using Umbraco.Core.Persistence.Querying;
-
-namespace Umbraco.Core.Services
-{
- ///
- /// Defines part of the MemberService, which is specific to methods used by the membership provider.
- ///
- ///
- /// Idea is to have this as an isolated interface so that it can be easily 'replaced' in the membership provider implementation.
- ///
- public interface IMembershipMemberService : IMembershipMemberService, IMembershipRoleService
- {
- ///
- /// Creates and persists a new Member
- ///
- /// Username of the Member to create
- /// Email of the Member to create
- /// which the Member should be based on
- ///
- IMember CreateMemberWithIdentity(string username, string email, IMemberType memberType);
- }
-
-
-}
diff --git a/src/Umbraco.Core/Services/Implement/ContentService.cs b/src/Umbraco.Core/Services/Implement/ContentService.cs
index 2fa75e2f3f..f255956971 100644
--- a/src/Umbraco.Core/Services/Implement/ContentService.cs
+++ b/src/Umbraco.Core/Services/Implement/ContentService.cs
@@ -27,17 +27,16 @@ namespace Umbraco.Core.Services.Implement
private readonly IContentTypeRepository _contentTypeRepository;
private readonly IDocumentBlueprintRepository _documentBlueprintRepository;
private readonly ILanguageRepository _languageRepository;
+ private readonly IPropertyValidationService _propertyValidationService;
private IQuery _queryNotTrashed;
- //TODO: The non-lazy object should be injected
- private readonly Lazy _propertyValidationService = new Lazy(() => new PropertyValidationService());
-
-
+
#region Constructors
public ContentService(IScopeProvider provider, ILogger logger,
IEventMessagesFactory eventMessagesFactory,
IDocumentRepository documentRepository, IEntityRepository entityRepository, IAuditRepository auditRepository,
- IContentTypeRepository contentTypeRepository, IDocumentBlueprintRepository documentBlueprintRepository, ILanguageRepository languageRepository)
+ IContentTypeRepository contentTypeRepository, IDocumentBlueprintRepository documentBlueprintRepository, ILanguageRepository languageRepository,
+ IPropertyValidationService propertyValidationService)
: base(provider, logger, eventMessagesFactory)
{
_documentRepository = documentRepository;
@@ -46,6 +45,7 @@ namespace Umbraco.Core.Services.Implement
_contentTypeRepository = contentTypeRepository;
_documentBlueprintRepository = documentBlueprintRepository;
_languageRepository = languageRepository;
+ _propertyValidationService = propertyValidationService;
}
#endregion
@@ -1404,7 +1404,7 @@ namespace Umbraco.Core.Services.Implement
//publish the culture values and validate the property values, if validation fails, log the invalid properties so the develeper has an idea of what has failed
IProperty[] invalidProperties = null;
var impact = CultureImpact.Explicit(culture, IsDefaultCulture(allLangs, culture));
- var tryPublish = d.PublishCulture(impact) && _propertyValidationService.Value.IsPropertyDataValid(d, out invalidProperties, impact);
+ var tryPublish = d.PublishCulture(impact) && _propertyValidationService.IsPropertyDataValid(d, out invalidProperties, impact);
if (invalidProperties != null && invalidProperties.Length > 0)
Logger.Warn("Scheduled publishing will fail for document {DocumentId} and culture {Culture} because of invalid properties {InvalidProperties}",
d.Id, culture, string.Join(",", invalidProperties.Select(x => x.Alias)));
@@ -1505,12 +1505,12 @@ namespace Umbraco.Core.Services.Implement
return culturesToPublish.All(culture =>
{
var impact = CultureImpact.Create(culture, IsDefaultCulture(allLangs, culture), content);
- return content.PublishCulture(impact) && _propertyValidationService.Value.IsPropertyDataValid(content, out _, impact);
+ return content.PublishCulture(impact) && _propertyValidationService.IsPropertyDataValid(content, out _, impact);
});
}
return content.PublishCulture(CultureImpact.Invariant)
- && _propertyValidationService.Value.IsPropertyDataValid(content, out _, CultureImpact.Invariant);
+ && _propertyValidationService.IsPropertyDataValid(content, out _, CultureImpact.Invariant);
}
// utility 'ShouldPublish' func used by SaveAndPublishBranch
@@ -2603,7 +2603,7 @@ namespace Umbraco.Core.Services.Implement
//validate the property values
IProperty[] invalidProperties = null;
- if (!impactsToPublish.All(x => _propertyValidationService.Value.IsPropertyDataValid(content, out invalidProperties, x)))
+ if (!impactsToPublish.All(x => _propertyValidationService.IsPropertyDataValid(content, out invalidProperties, x)))
return new PublishResult(PublishResultType.FailedPublishContentInvalid, evtMsgs, content)
{
InvalidProperties = invalidProperties
diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj
index 99ce0ec07c..056e1a086b 100755
--- a/src/Umbraco.Core/Umbraco.Core.csproj
+++ b/src/Umbraco.Core/Umbraco.Core.csproj
@@ -203,7 +203,6 @@
-
@@ -236,10 +235,7 @@
-
-
-
@@ -651,7 +647,6 @@
-
@@ -804,7 +799,6 @@
-