Bugfix - Container resolvers & conflict issues
This commit is contained in:
@@ -15,11 +15,9 @@ namespace Umbraco.Core.Dictionary
|
||||
/// Initializes the resolver to use IoC
|
||||
/// </summary>
|
||||
/// <param name="container"></param>
|
||||
/// <param name="implementationType"></param>
|
||||
internal CultureDictionaryFactoryResolver(IServiceContainer container, Type implementationType)
|
||||
: base(container, implementationType)
|
||||
{
|
||||
}
|
||||
internal CultureDictionaryFactoryResolver(IServiceContainer container)
|
||||
: base(container)
|
||||
{ }
|
||||
|
||||
internal CultureDictionaryFactoryResolver(ICultureDictionaryFactory factory)
|
||||
: base(factory)
|
||||
|
||||
@@ -9,16 +9,6 @@ namespace Umbraco.Core.Models.PublishedContent
|
||||
/// </summary>
|
||||
public class PublishedContentModelFactoryResolver : ContainerSingleObjectResolver<PublishedContentModelFactoryResolver, IPublishedContentModelFactory>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes the resolver to use IoC
|
||||
/// </summary>
|
||||
/// <param name="container"></param>
|
||||
/// <param name="implementationType"></param>
|
||||
internal PublishedContentModelFactoryResolver(IServiceContainer container, Type implementationType)
|
||||
: base(container, implementationType)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PublishedContentModelFactoryResolver"/>.
|
||||
/// </summary>
|
||||
@@ -37,13 +27,12 @@ namespace Umbraco.Core.Models.PublishedContent
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initialize the resolver to use IoC, when using this contructor the type must be set manually
|
||||
/// Initialize the resolver to use IoC
|
||||
/// </summary>
|
||||
/// <param name="container"></param>
|
||||
internal PublishedContentModelFactoryResolver(IServiceContainer container)
|
||||
: base(container)
|
||||
{
|
||||
}
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Sets the factory.
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Umbraco.Core.ObjectResolution
|
||||
Container = container;
|
||||
|
||||
//Register ourselves in the case that a resolver instance should be injected someplace
|
||||
Container.Register<TResolver>(factory => (TResolver)(object)this);
|
||||
Container.Register(factory => (TResolver)(object)this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using LightInject;
|
||||
using Umbraco.Core.Persistence.Migrations.Syntax.Create;
|
||||
|
||||
namespace Umbraco.Core.ObjectResolution
|
||||
{
|
||||
@@ -41,21 +41,8 @@ namespace Umbraco.Core.ObjectResolution
|
||||
internal ContainerSingleObjectResolver(TResolved value, bool canBeNull)
|
||||
: base(value, canBeNull)
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the resolver to use IoC
|
||||
/// </summary>
|
||||
/// <param name="container"></param>
|
||||
/// <param name="implementationType"></param>
|
||||
internal ContainerSingleObjectResolver(IServiceContainer container, Type implementationType)
|
||||
{
|
||||
if (container == null) throw new ArgumentNullException("container");
|
||||
if (implementationType == null) throw new ArgumentNullException("implementationType");
|
||||
_container = container;
|
||||
_container.Register(typeof(TResolved), implementationType, new PerContainerLifetime());
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Initialize the resolver to use IoC, when using this contructor the type must be set manually
|
||||
@@ -63,7 +50,7 @@ namespace Umbraco.Core.ObjectResolution
|
||||
/// <param name="container"></param>
|
||||
internal ContainerSingleObjectResolver(IServiceContainer container)
|
||||
{
|
||||
if (container == null) throw new ArgumentNullException("container");
|
||||
if (container == null) throw new ArgumentNullException(nameof(container));
|
||||
_container = container;
|
||||
}
|
||||
|
||||
@@ -75,7 +62,7 @@ namespace Umbraco.Core.ObjectResolution
|
||||
internal ContainerSingleObjectResolver(IServiceContainer container, Func<IServiceFactory, TResolved> implementationType)
|
||||
{
|
||||
_container = container;
|
||||
_container.Register<TResolved>(implementationType, new PerContainerLifetime());
|
||||
_container.Register(implementationType, new PerContainerLifetime());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -89,8 +76,9 @@ namespace Umbraco.Core.ObjectResolution
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_container == null) return base.Value;
|
||||
return _container.GetInstance<TResolved>();
|
||||
return _container == null
|
||||
? base.Value
|
||||
: _container.GetInstance<TResolved>();
|
||||
}
|
||||
set
|
||||
{
|
||||
@@ -102,7 +90,7 @@ namespace Umbraco.Core.ObjectResolution
|
||||
{
|
||||
// must override with the proper name!
|
||||
_container.Override(
|
||||
sr => sr.ServiceType == typeof (TResolved) && sr.ServiceName == GetType().FullName,
|
||||
sr => sr.ServiceType == typeof (TResolved),
|
||||
(factory, registration) =>
|
||||
{
|
||||
registration.Value = value;
|
||||
@@ -116,8 +104,9 @@ namespace Umbraco.Core.ObjectResolution
|
||||
_container.Register(new ServiceRegistration
|
||||
{
|
||||
ServiceType = typeof (TResolved),
|
||||
ImplementingType = value.GetType(),
|
||||
ServiceName = GetType().FullName,
|
||||
// no! use Value below!
|
||||
//ImplementingType = value.GetType(),
|
||||
ServiceName = "",
|
||||
Lifetime = new PerContainerLifetime(),
|
||||
Value = value
|
||||
});
|
||||
@@ -134,7 +123,7 @@ namespace Umbraco.Core.ObjectResolution
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_container == null) return base.HasValue;
|
||||
if (_container == null) return base.HasValue;
|
||||
return (_container.TryGetInstance<TResolved>() == null) == false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,9 +14,8 @@ namespace Umbraco.Core.Strings
|
||||
/// Initializes the resolver to use IoC
|
||||
/// </summary>
|
||||
/// <param name="container"></param>
|
||||
/// <param name="implementationType"></param>
|
||||
internal ShortStringHelperResolver(IServiceContainer container, Type implementationType)
|
||||
: base(container, implementationType)
|
||||
internal ShortStringHelperResolver(IServiceContainer container)
|
||||
: base(container)
|
||||
{
|
||||
Resolution.Frozen += (sender, args) => Value.Freeze();
|
||||
}
|
||||
|
||||
@@ -10,15 +10,13 @@ namespace Umbraco.Core.Sync
|
||||
/// </summary>
|
||||
public sealed class ServerMessengerResolver : ContainerSingleObjectResolver<ServerMessengerResolver, IServerMessenger>
|
||||
{
|
||||
internal ServerMessengerResolver(IServiceContainer container, Type implementationType)
|
||||
: base(container, implementationType)
|
||||
{
|
||||
}
|
||||
internal ServerMessengerResolver(IServiceContainer container)
|
||||
: base(container)
|
||||
{ }
|
||||
|
||||
internal ServerMessengerResolver(IServiceContainer container, Func<IServiceFactory, IServerMessenger> implementationType)
|
||||
: base(container, implementationType)
|
||||
{
|
||||
}
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Sets the messenger.
|
||||
|
||||
@@ -15,18 +15,17 @@ namespace Umbraco.Core.Sync
|
||||
/// </summary>
|
||||
/// <param name="value">An instance of a registrar.</param>
|
||||
/// <remarks>The resolver is created by the <c>CoreBootManager</c> and thus the constructor remains internal.</remarks>
|
||||
public ServerRegistrarResolver(IServerRegistrar value) : base(value)
|
||||
{
|
||||
}
|
||||
internal ServerRegistrarResolver(IServiceContainer container, Type implementationType)
|
||||
: base(container, implementationType)
|
||||
{
|
||||
}
|
||||
public ServerRegistrarResolver(IServerRegistrar value)
|
||||
: base(value)
|
||||
{ }
|
||||
|
||||
internal ServerRegistrarResolver(IServiceContainer container)
|
||||
: base(container)
|
||||
{ }
|
||||
|
||||
internal ServerRegistrarResolver(IServiceContainer container, Func<IServiceFactory, IServerRegistrar> implementationType)
|
||||
: base(container, implementationType)
|
||||
{
|
||||
}
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Sets the registrar.
|
||||
|
||||
Reference in New Issue
Block a user