2012-08-14 12:03:34 +06:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using umbraco.interfaces;
|
|
|
|
|
|
2013-01-29 09:45:12 +06:00
|
|
|
namespace Umbraco.Core.ObjectResolution
|
2012-08-14 12:03:34 +06:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// A resolver to return all IApplicationEvents objects
|
|
|
|
|
/// </summary>
|
2013-02-14 23:05:58 +06:00
|
|
|
internal sealed class ApplicationEventsResolver : ManyObjectsResolverBase<ApplicationEventsResolver, IApplicationEventHandler>
|
2012-08-14 12:03:34 +06:00
|
|
|
{
|
|
|
|
|
|
2013-02-14 23:05:58 +06:00
|
|
|
private readonly LegacyStartupHandlerResolver _legacyResolver;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2012-08-14 12:03:34 +06:00
|
|
|
/// Constructor
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="applicationEventHandlers"></param>
|
|
|
|
|
internal ApplicationEventsResolver(IEnumerable<Type> applicationEventHandlers)
|
|
|
|
|
: base(applicationEventHandlers)
|
|
|
|
|
{
|
2013-02-14 23:05:58 +06:00
|
|
|
//create the legacy resolver and only include the legacy types
|
|
|
|
|
_legacyResolver = new LegacyStartupHandlerResolver(
|
|
|
|
|
applicationEventHandlers.Where(x => !TypeHelper.IsTypeAssignableFrom<IApplicationEventHandler>(x)));
|
2012-08-14 12:03:34 +06:00
|
|
|
}
|
|
|
|
|
|
2013-02-14 23:05:58 +06:00
|
|
|
/// <summary>
|
|
|
|
|
/// Override in order to only return types of IApplicationEventHandler and above,
|
|
|
|
|
/// do not include the legacy types of IApplicationStartupHandler
|
|
|
|
|
/// </summary>
|
|
|
|
|
protected override IEnumerable<Type> InstanceTypes
|
|
|
|
|
{
|
|
|
|
|
get { return base.InstanceTypes.Where(TypeHelper.IsTypeAssignableFrom<IApplicationEventHandler>); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2012-08-22 05:21:02 +06:00
|
|
|
/// Gets the <see cref="IApplicationEventHandler"/> implementations.
|
2012-08-14 12:03:34 +06:00
|
|
|
/// </summary>
|
2012-08-22 05:21:02 +06:00
|
|
|
public IEnumerable<IApplicationEventHandler> ApplicationEventHandlers
|
2012-08-14 12:03:34 +06:00
|
|
|
{
|
2013-02-14 23:05:58 +06:00
|
|
|
get { return Values; }
|
2012-08-14 12:03:34 +06:00
|
|
|
}
|
|
|
|
|
|
2013-02-14 23:05:58 +06:00
|
|
|
/// <summary>
|
|
|
|
|
/// Create instances of all of the legacy startup handlers
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void InstantiateLegacyStartupHanlders()
|
|
|
|
|
{
|
|
|
|
|
//this will instantiate them all
|
|
|
|
|
var handlers = _legacyResolver.LegacyStartupHandlers;
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-13 10:59:21 +05:00
|
|
|
protected override bool SupportsClear
|
2012-08-14 12:03:34 +06:00
|
|
|
{
|
2012-10-13 10:59:21 +05:00
|
|
|
get { return false; }
|
2012-10-31 11:36:22 +06:00
|
|
|
}
|
2012-08-14 12:03:34 +06:00
|
|
|
|
2012-10-13 10:59:21 +05:00
|
|
|
protected override bool SupportsInsert
|
2012-08-14 12:03:34 +06:00
|
|
|
{
|
2012-10-13 10:59:21 +05:00
|
|
|
get { return false; }
|
2012-08-14 12:03:34 +06:00
|
|
|
}
|
|
|
|
|
|
2013-02-14 23:05:58 +06:00
|
|
|
private class LegacyStartupHandlerResolver : ManyObjectsResolverBase<ApplicationEventsResolver, IApplicationStartupHandler>
|
|
|
|
|
{
|
|
|
|
|
internal LegacyStartupHandlerResolver(IEnumerable<Type> legacyStartupHandlers)
|
|
|
|
|
: base(legacyStartupHandlers)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEnumerable<IApplicationStartupHandler> LegacyStartupHandlers
|
|
|
|
|
{
|
|
|
|
|
get { return Values; }
|
|
|
|
|
}
|
2013-02-14 23:55:39 +06:00
|
|
|
}
|
2013-02-14 23:14:43 +06:00
|
|
|
|
2012-08-14 12:03:34 +06:00
|
|
|
}
|
|
|
|
|
}
|