diff --git a/build/NuSpecs/UmbracoCms.Core.nuspec b/build/NuSpecs/UmbracoCms.Core.nuspec
index b257f8dcdd..fead7a0cce 100644
--- a/build/NuSpecs/UmbracoCms.Core.nuspec
+++ b/build/NuSpecs/UmbracoCms.Core.nuspec
@@ -22,7 +22,6 @@
the latter would pick anything below 3.0.0 and that includes prereleases such as 3.0.0-alpha, and we do
not want this to happen as the alpha of the next major is, really, the next major already.
-->
-
diff --git a/src/Umbraco.Core/BindingRedirects.cs b/src/Umbraco.Core/BindingRedirects.cs
index 17e187b7ae..fc50b73a17 100644
--- a/src/Umbraco.Core/BindingRedirects.cs
+++ b/src/Umbraco.Core/BindingRedirects.cs
@@ -27,11 +27,14 @@ namespace Umbraco.Core
///
private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
+ // keep here for reference - we don't use AutoMapper
+ /*
//AutoMapper:
// ensure the assembly is indeed AutoMapper and that the PublicKeyToken is null before trying to Load again
// do NOT just replace this with 'return Assembly', as it will cause an infinite loop -> stackoverflow
if (args.Name.StartsWith("AutoMapper") && args.Name.EndsWith("PublicKeyToken=null"))
return Assembly.Load(args.Name.Replace(", PublicKeyToken=null", ", PublicKeyToken=be96cd2c38ef1005"));
+ */
return null;
diff --git a/src/Umbraco.Core/Mapping/Mapper.cs b/src/Umbraco.Core/Mapping/Mapper.cs
index 36c7462d8b..377575fed6 100644
--- a/src/Umbraco.Core/Mapping/Mapper.cs
+++ b/src/Umbraco.Core/Mapping/Mapper.cs
@@ -1,19 +1,11 @@
using System;
-using System.CodeDom;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace Umbraco.Core.Mapping
{
- // FIXME we should inject the mapper
- // FIXME in order to transition, this should also handle AutoMapper?
- // FIXME we might have to manage a 'context' for some contextual mappings?
- // FIXME we have an infinite loop problem w/ logging in due to mapping issues
- // FIXME refactor
- // ctor: (source, context) =>
- // map: (source, target, context) =>
- // and context.Mapper is mapper
+ // FIXME needs documentation and cleanup!
public class Mapper
{
@@ -31,21 +23,12 @@ namespace Umbraco.Core.Mapping
#region Define
- //public void Define()
- // => Define((source, target) => { });
-
public void Define()
=> Define((source, target, context) => { });
- //public void Define(Action map)
- // => Define(source => throw new NotSupportedException($"Don't know how to create {typeof(TTarget)} instances."), map);
-
public void Define(Action map)
=> Define((source, context) => throw new NotSupportedException($"Don't know how to create {typeof(TTarget)} instances."), map);
- //public void Define(Func ctor)
- // => Define(ctor, (source, target) => { });
-
public void Define(Func ctor)
=> Define(ctor, (source, target, context) => { });
@@ -63,42 +46,6 @@ namespace Umbraco.Core.Mapping
return sourceMap;
}
- //public void Define(Func ctor, Action map)
- //{
- // var sourceType = typeof(TSource);
- // var targetType = typeof(TTarget);
-
- // var sourceCtors = DefineCtors(sourceType);
- // sourceCtors[targetType] = (source, context) => ctor((TSource) source);
-
- // var sourceMaps = DefineMaps(sourceType);
- // sourceMaps[targetType] = (source, target, context) => map((TSource) source, (TTarget) target);
- //}
-
- //public void Define(Func ctor, Action map)
- //{
- // var sourceType = typeof(TSource);
- // var targetType = typeof(TTarget);
-
- // var sourceCtors = DefineCtors(sourceType);
- // sourceCtors[targetType] = (source, context) => ctor((TSource)source);
-
- // var sourceMaps = DefineMaps(sourceType);
- // sourceMaps[targetType] = (source, target, context) => map((TSource)source, (TTarget)target, context);
- //}
-
- //public void Define(Func ctor, Action map)
- //{
- // var sourceType = typeof(TSource);
- // var targetType = typeof(TTarget);
-
- // var sourceCtors = DefineCtors(sourceType);
- // sourceCtors[targetType] = (source, context) => ctor((TSource)source, context);
-
- // var sourceMaps = DefineMaps(sourceType);
- // sourceMaps[targetType] = (source, target, context) => map((TSource)source, (TTarget)target);
- //}
-
public void Define(Func ctor, Action map)
{
var sourceType = typeof(TSource);
@@ -186,15 +133,10 @@ namespace Umbraco.Core.Mapping
return (TTarget)targetEnumerable;
}
-
- // fixme - temp
- return AutoMapper.Mapper.Map(source);
}
}
- // fixme this is temp
- //throw new InvalidOperationException($"Don't know how to map {sourceType.FullName} to {targetType.FullName}.");
- return AutoMapper.Mapper.Map(source);
+ throw new InvalidOperationException($"Don't know how to map {sourceType.FullName} to {targetType.FullName}.");
}
// TODO: when AutoMapper is completely gone these two methods can merge
@@ -254,15 +196,10 @@ namespace Umbraco.Core.Mapping
return (TTarget)targetEnumerable;
}
-
- // fixme - temp
- return AutoMapper.Mapper.Map(source);
}
}
- // fixme this is temp
- //throw new InvalidOperationException($"Don't know how to map {sourceType.FullName} to {targetType.FullName}.");
- return AutoMapper.Mapper.Map(source);
+ throw new InvalidOperationException($"Don't know how to map {sourceType.FullName} to {targetType.FullName}.");
}
public TTarget Map(TSource source, TTarget target)
@@ -275,7 +212,6 @@ namespace Umbraco.Core.Mapping
return Map(source, target, context);
}
-
public TTarget Map(TSource source, TTarget target, MapperContext context)
{
// fixme should we deal with enumerables?
@@ -283,9 +219,7 @@ namespace Umbraco.Core.Mapping
var map = GetMap(source.GetType(), typeof(TTarget));
if (map == null)
{
- // fixme this is temp
- //throw new InvalidOperationException($"Don't know how to map {sourceType.FullName} to {targetType.FullName}.");
- return AutoMapper.Mapper.Map(source, target);
+ throw new InvalidOperationException($"Don't know how to map {typeof(TSource).FullName} to {typeof(TTarget).FullName}.");
}
map(source, target, context);
diff --git a/src/Umbraco.Core/Runtime/CoreInitialComponent.cs b/src/Umbraco.Core/Runtime/CoreInitialComponent.cs
index 25b679b2a0..2e40bf1339 100644
--- a/src/Umbraco.Core/Runtime/CoreInitialComponent.cs
+++ b/src/Umbraco.Core/Runtime/CoreInitialComponent.cs
@@ -1,28 +1,12 @@
-using System.Collections.Generic;
-using AutoMapper;
-using Umbraco.Core.Composing;
+using Umbraco.Core.Composing;
using Umbraco.Core.IO;
namespace Umbraco.Core.Runtime
{
public class CoreInitialComponent : IComponent
{
- private readonly IEnumerable _mapperProfiles;
-
- public CoreInitialComponent(IEnumerable mapperProfiles) // fixme - this is what we want to kill: mapper
- {
- _mapperProfiles = mapperProfiles;
- }
-
public void Initialize()
{
- // mapper profiles have been registered & are created by the container
- Mapper.Initialize(configuration =>
- {
- foreach (var profile in _mapperProfiles)
- configuration.AddProfile(profile);
- });
-
// ensure we have some essential directories
// every other component can then initialize safely
IOHelper.EnsurePathExists("~/App_Data");
diff --git a/src/Umbraco.Core/Runtime/CoreRuntime.cs b/src/Umbraco.Core/Runtime/CoreRuntime.cs
index f00365496a..bc7b8afc3b 100644
--- a/src/Umbraco.Core/Runtime/CoreRuntime.cs
+++ b/src/Umbraco.Core/Runtime/CoreRuntime.cs
@@ -217,10 +217,13 @@ namespace Umbraco.Core.Runtime
// This is used for loading a signed assembly of AutoMapper (v. 3.1+) without having to recompile old code.
AppDomain.CurrentDomain.AssemblyResolve += (sender, args) =>
{
+ // here for reference - we don't use automapper anymore + see BindingRedirects ??
+ /*
// ensure the assembly is indeed AutoMapper and that the PublicKeyToken is null before trying to Load again
// do NOT just replace this with 'return Assembly', as it will cause an infinite loop -> stack overflow
if (args.Name.StartsWith("AutoMapper") && args.Name.EndsWith("PublicKeyToken=null"))
return Assembly.Load(args.Name.Replace(", PublicKeyToken=null", ", PublicKeyToken=be96cd2c38ef1005"));
+ */
return null;
};
}
diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj
index e7203b3be8..c2839792bd 100755
--- a/src/Umbraco.Core/Umbraco.Core.csproj
+++ b/src/Umbraco.Core/Umbraco.Core.csproj
@@ -60,7 +60,6 @@
runtime; build; native; contentfiles; analyzers
all
-
diff --git a/src/Umbraco.Tests/Mapping/MappingTests.cs b/src/Umbraco.Tests/Mapping/MappingTests.cs
index 07930bf027..c5f4593c6d 100644
--- a/src/Umbraco.Tests/Mapping/MappingTests.cs
+++ b/src/Umbraco.Tests/Mapping/MappingTests.cs
@@ -79,13 +79,12 @@ namespace Umbraco.Tests.Mapping
{
public void SetMaps(Mapper mapper)
{
- mapper.Define(source => new Thing2(), (source, target) => Map(source, target));
+ mapper.Define((source, context) => new Thing2(), Map);
}
- private Thing2 Map(Thing1 source, Thing2 target)
+ private void Map(Thing1 source, Thing2 target, MapperContext context)
{
target.Value = source.Value;
- return target;
}
}
}
diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj
index 706d81700b..17cb425eef 100644
--- a/src/Umbraco.Tests/Umbraco.Tests.csproj
+++ b/src/Umbraco.Tests/Umbraco.Tests.csproj
@@ -78,7 +78,6 @@
-
diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj
index 8fb0dc6cd9..6777e66456 100644
--- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj
+++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj
@@ -83,7 +83,6 @@
-
diff --git a/src/Umbraco.Web/Composing/CompositionExtensions/WebMappingProfiles.cs b/src/Umbraco.Web/Composing/CompositionExtensions/WebMappingProfiles.cs
index 88fb595440..d0c404a679 100644
--- a/src/Umbraco.Web/Composing/CompositionExtensions/WebMappingProfiles.cs
+++ b/src/Umbraco.Web/Composing/CompositionExtensions/WebMappingProfiles.cs
@@ -1,10 +1,7 @@
-using AutoMapper;
-using Umbraco.Core;
+using Umbraco.Core;
using Umbraco.Core.Composing;
using Umbraco.Core.Mapping;
-using Umbraco.Core.Models;
using Umbraco.Web.Models.Mapping;
-using Umbraco.Web.Trees;
namespace Umbraco.Web.Composing.CompositionExtensions
{
@@ -12,10 +9,10 @@ namespace Umbraco.Web.Composing.CompositionExtensions
{
public static Composition ComposeWebMappingProfiles(this Composition composition)
{
- // register the profiles
composition.WithCollectionBuilder()
.Append()
.Append()
+ .Append()
.Append()
.Append()
.Append()
@@ -23,6 +20,7 @@ namespace Umbraco.Web.Composing.CompositionExtensions
.Append()
.Append()
.Append()
+ .Append()
.Append()
.Append()
.Append()
@@ -31,37 +29,7 @@ namespace Umbraco.Web.Composing.CompositionExtensions
.Append()
.Append();
- //register the profiles
- //composition.Register();
- //composition.Register();
- composition.Register();
- //composition.Register();
- //composition.Register();
- //composition.Register();
- //composition.Register();
- //composition.Register();
- //composition.Register();
- //composition.Register();
- composition.Register();
- //composition.Register();
- //composition.Register();
- //composition.Register();
- //composition.Register();
- //composition.Register();
- //composition.Register();
- //composition.Register();
-
- //register any resolvers, etc.. that the profiles use
- composition.Register();
- composition.Register>();
- composition.Register>();
- composition.Register>();
- composition.Register>();
- composition.Register();
- composition.Register();
- composition.Register();
- composition.Register();
- composition.Register();
+ composition.Register();
return composition;
}
diff --git a/src/Umbraco.Web/Editors/Binders/ContentItemBinder.cs b/src/Umbraco.Web/Editors/Binders/ContentItemBinder.cs
index ca7cb2e4e2..11a876345d 100644
--- a/src/Umbraco.Web/Editors/Binders/ContentItemBinder.cs
+++ b/src/Umbraco.Web/Editors/Binders/ContentItemBinder.cs
@@ -2,7 +2,6 @@
using System.Linq;
using System.Web.Http.Controllers;
using System.Web.Http.ModelBinding;
-using AutoMapper;
using Umbraco.Core;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
diff --git a/src/Umbraco.Web/Editors/Binders/MediaItemBinder.cs b/src/Umbraco.Web/Editors/Binders/MediaItemBinder.cs
index bbba9d8122..1084aa16ea 100644
--- a/src/Umbraco.Web/Editors/Binders/MediaItemBinder.cs
+++ b/src/Umbraco.Web/Editors/Binders/MediaItemBinder.cs
@@ -1,14 +1,10 @@
using System;
using System.Web.Http.Controllers;
using System.Web.Http.ModelBinding;
-using AutoMapper;
-using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Core.Services;
using Umbraco.Web.Composing;
using Umbraco.Web.Models.ContentEditing;
-using Umbraco.Web.Models.Mapping;
-using Umbraco.Web.WebApi;
namespace Umbraco.Web.Editors.Binders
{
@@ -46,7 +42,7 @@ namespace Umbraco.Web.Editors.Binders
//create the dto from the persisted model
if (model.PersistedContent != null)
{
- model.PropertyCollectionDto = Mapper.Map(model.PersistedContent);
+ model.PropertyCollectionDto = Current.Mapper.Map(model.PersistedContent);
//now map all of the saved values to the dto
_modelBinderHelper.MapPropertyValuesFromSaved(model, model.PropertyCollectionDto);
}
diff --git a/src/Umbraco.Web/Editors/Binders/MemberBinder.cs b/src/Umbraco.Web/Editors/Binders/MemberBinder.cs
index bceba2e04d..60b4f85c21 100644
--- a/src/Umbraco.Web/Editors/Binders/MemberBinder.cs
+++ b/src/Umbraco.Web/Editors/Binders/MemberBinder.cs
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Web.Http.Controllers;
using System.Web.Http.ModelBinding;
using System.Web.Security;
-using AutoMapper;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Core.Security;
@@ -50,7 +49,7 @@ namespace Umbraco.Web.Editors.Binders
//create the dto from the persisted model
if (model.PersistedContent != null)
{
- model.PropertyCollectionDto = Mapper.Map(model.PersistedContent);
+ model.PropertyCollectionDto = Current.Mapper.Map(model.PersistedContent);
//now map all of the saved values to the dto
_modelBinderHelper.MapPropertyValuesFromSaved(model, model.PropertyCollectionDto);
}
@@ -106,7 +105,7 @@ namespace Umbraco.Web.Editors.Binders
//}
//member.Key = convertResult.Result;
- var member = Mapper.Map(membershipUser);
+ var member = Current.Mapper.Map(membershipUser);
return member;
}
diff --git a/src/Umbraco.Web/Editors/ContentTypeControllerBase.cs b/src/Umbraco.Web/Editors/ContentTypeControllerBase.cs
index 0fa3428740..e62438cc6f 100644
--- a/src/Umbraco.Web/Editors/ContentTypeControllerBase.cs
+++ b/src/Umbraco.Web/Editors/ContentTypeControllerBase.cs
@@ -5,7 +5,6 @@ using System.Net;
using System.Net.Http;
using System.Text;
using System.Web.Http;
-using AutoMapper;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Configuration;
@@ -501,13 +500,13 @@ namespace Umbraco.Web.Editors
where TPropertyType : PropertyTypeBasic
{
InvalidCompositionException invalidCompositionException = null;
- if (ex is AutoMapperMappingException && ex.InnerException is InvalidCompositionException)
+ if (ex is InvalidCompositionException)
{
- invalidCompositionException = (InvalidCompositionException)ex.InnerException;
+ invalidCompositionException = (InvalidCompositionException)ex;
}
else if (ex.InnerException is InvalidCompositionException)
{
- invalidCompositionException = (InvalidCompositionException)ex;
+ invalidCompositionException = (InvalidCompositionException)ex.InnerException;
}
if (invalidCompositionException != null)
{
diff --git a/src/Umbraco.Web/Editors/DataTypeValidateAttribute.cs b/src/Umbraco.Web/Editors/DataTypeValidateAttribute.cs
index 738dd05c75..1337545ee0 100644
--- a/src/Umbraco.Web/Editors/DataTypeValidateAttribute.cs
+++ b/src/Umbraco.Web/Editors/DataTypeValidateAttribute.cs
@@ -4,7 +4,6 @@ using System.Net;
using System.Net.Http;
using System.Web.Http.Controllers;
using System.Web.Http.Filters;
-using AutoMapper;
using Umbraco.Core;
using Umbraco.Core.Composing;
using Umbraco.Core.Models;
@@ -71,12 +70,12 @@ namespace Umbraco.Web.Editors
return;
}
// map the model to the persisted instance
- Mapper.Map(dataType, persisted);
+ Current.Mapper.Map(dataType, persisted);
break;
case ContentSaveAction.SaveNew:
// create the persisted model from mapping the saved model
- persisted = Mapper.Map(dataType);
+ persisted = Current.Mapper.Map(dataType);
((DataType) persisted).ResetIdentity();
break;
diff --git a/src/Umbraco.Web/Models/Mapping/ActionButtonsResolver.cs b/src/Umbraco.Web/Models/Mapping/ActionButtonsResolver.cs
deleted file mode 100644
index 9c5a4a0b88..0000000000
--- a/src/Umbraco.Web/Models/Mapping/ActionButtonsResolver.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Umbraco.Core.Models;
-using Umbraco.Core.Services;
-using Umbraco.Web.Composing;
-
-namespace Umbraco.Web.Models.Mapping
-{
- ///
- /// Creates the list of action buttons allowed for this user - Publish, Send to publish, save, unpublish returned as the button's 'letter'
- ///
- internal class ActionButtonsResolver
- {
- public ActionButtonsResolver(IUserService userService, IContentService contentService)
- {
- UserService = userService;
- ContentService = contentService;
- }
-
- private IUserService UserService { get; }
- private IContentService ContentService { get; }
-
- public IEnumerable Resolve(IContent source)
- {
- //cannot check permissions without a context
- if (Current.UmbracoContext == null)
- return Enumerable.Empty();
-
- string path;
- if (source.HasIdentity)
- path = source.Path;
- else
- {
- var parent = ContentService.GetById(source.ParentId);
- path = parent == null ? "-1" : parent.Path;
- }
-
- // TODO: This is certainly not ideal usage here - perhaps the best way to deal with this in the future is
- // with the IUmbracoContextAccessor. In the meantime, if used outside of a web app this will throw a null
- // reference exception :(
- return UserService.GetPermissionsForPath(Current.UmbracoContext.Security.CurrentUser, path).GetAllPermissions();
- }
- }
-}
diff --git a/src/Umbraco.Web/Models/Mapping/AuditMapperProfile.cs b/src/Umbraco.Web/Models/Mapping/AuditMapperProfile.cs
index 56bd48ee17..e7756b4538 100644
--- a/src/Umbraco.Web/Models/Mapping/AuditMapperProfile.cs
+++ b/src/Umbraco.Web/Models/Mapping/AuditMapperProfile.cs
@@ -8,11 +8,11 @@ namespace Umbraco.Web.Models.Mapping
{
public void SetMaps(Mapper mapper)
{
- mapper.Define(source => new AuditLog(), Map);
+ mapper.Define((source, context) => new AuditLog(), Map);
}
// Umbraco.Code.MapAll -UserAvatars -UserName
- private void Map(IAuditItem source, AuditLog target)
+ private void Map(IAuditItem source, AuditLog target, MapperContext context)
{
target.UserId = source.UserId;
target.NodeId = source.Id;
diff --git a/src/Umbraco.Web/Models/Mapping/CodeFileMapperProfile.cs b/src/Umbraco.Web/Models/Mapping/CodeFileMapperProfile.cs
index 7767bcd2ee..735125d4b1 100644
--- a/src/Umbraco.Web/Models/Mapping/CodeFileMapperProfile.cs
+++ b/src/Umbraco.Web/Models/Mapping/CodeFileMapperProfile.cs
@@ -9,17 +9,17 @@ namespace Umbraco.Web.Models.Mapping
{
public void SetMaps(Mapper mapper)
{
- mapper.Define(source => new EntityBasic(), Map);
- mapper.Define(source => new CodeFileDisplay(), Map);
- mapper.Define