DataTypeValidateAttribute now uses bastard injection.
Notes on the UmbracoModule. Need to abstract resolving via Current.Container to remove LightInject refs.
This commit is contained in:
@@ -23,7 +23,8 @@ namespace Umbraco.Tests.Routing
|
||||
public override void SetUp()
|
||||
{
|
||||
base.SetUp();
|
||||
|
||||
|
||||
// fixme - use the full injected ctor, then we can ditch this one.
|
||||
//create the module
|
||||
_module = new UmbracoModule
|
||||
{
|
||||
|
||||
@@ -5,14 +5,15 @@ using System.Net.Http;
|
||||
using System.Web.Http.Controllers;
|
||||
using System.Web.Http.Filters;
|
||||
using AutoMapper;
|
||||
using LightInject;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Composing;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using Umbraco.Web.WebApi;
|
||||
|
||||
using LightInject;
|
||||
|
||||
namespace Umbraco.Web.Editors
|
||||
{
|
||||
@@ -21,13 +22,25 @@ namespace Umbraco.Web.Editors
|
||||
/// </summary>
|
||||
internal sealed class DataTypeValidateAttribute : ActionFilterAttribute
|
||||
{
|
||||
// LightInject can inject dependencies into properties
|
||||
public IDataTypeService DataTypeService { get; }
|
||||
|
||||
[Inject]
|
||||
public IDataTypeService DataTypeService { get; set; }
|
||||
public PropertyEditorCollection PropertyEditors { get; }
|
||||
|
||||
[Inject]
|
||||
public PropertyEditorCollection PropertyEditors { get; set; }
|
||||
public DataTypeValidateAttribute()
|
||||
: this(Current.Container.GetInstance<IDataTypeService>(), Current.Container.GetInstance<PropertyEditorCollection>())
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For use in unit tests. Not possible to use as attribute ctor.
|
||||
/// </summary>
|
||||
/// <param name="dataTypeService"></param>
|
||||
/// <param name="propertyEditors"></param>
|
||||
public DataTypeValidateAttribute(IDataTypeService dataTypeService, PropertyEditorCollection propertyEditors)
|
||||
{
|
||||
DataTypeService = dataTypeService;
|
||||
PropertyEditors = propertyEditors;
|
||||
}
|
||||
|
||||
public override void OnActionExecuting(HttpActionContext actionContext)
|
||||
{
|
||||
|
||||
@@ -93,7 +93,8 @@ namespace Umbraco.Web
|
||||
internal IVariationContextAccessor VariationContextAccessor { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
// fixme - delete, just one usage in a test.
|
||||
public UmbracoModule()
|
||||
: this(
|
||||
Current.Container.GetInstance<IUmbracoSettingsSection>(),
|
||||
|
||||
Reference in New Issue
Block a user