Changed the ILookup resolution, now that DocumentRequest object contains everything to do the lookups
we don't have to create each ILookup per request, these can exist one per application.
This commit is contained in:
@@ -8,33 +8,49 @@ using umbraco.BusinessLogic.Utils;
|
||||
namespace Umbraco.Web
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods for the PluginResolver
|
||||
/// </summary>
|
||||
public static class PluginResolverExtensions
|
||||
{
|
||||
/// Extension methods for the PluginResolver
|
||||
/// </summary>
|
||||
public static class PluginResolverExtensions
|
||||
{
|
||||
|
||||
private static volatile IEnumerable<Type> _lookups;
|
||||
private static readonly object Locker = new object();
|
||||
private static volatile IEnumerable<ILookup> _lookups;
|
||||
private static readonly object Locker = new object();
|
||||
|
||||
/// <summary>
|
||||
/// Returns all available ILookup objects
|
||||
/// </summary>
|
||||
/// <param name="plugins"></param>
|
||||
/// <returns></returns>
|
||||
internal static IEnumerable<Type> ResolveLookups(this PluginResolver plugins)
|
||||
{
|
||||
if (_lookups == null)
|
||||
{
|
||||
lock(Locker)
|
||||
{
|
||||
if (_lookups == null)
|
||||
{
|
||||
_lookups = TypeFinder.FindClassesOfType<ILookup>();
|
||||
}
|
||||
}
|
||||
}
|
||||
return _lookups;
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns all available ILookup objects
|
||||
/// </summary>
|
||||
/// <param name="plugins"></param>
|
||||
/// <returns></returns>
|
||||
internal static IEnumerable<ILookup> ResolveLookups(this PluginResolver plugins)
|
||||
{
|
||||
if (_lookups == null)
|
||||
{
|
||||
lock (Locker)
|
||||
{
|
||||
if (_lookups == null)
|
||||
{
|
||||
var lookupTypes = TypeFinder.FindClassesOfType<ILookup>();
|
||||
var lookups = new List<ILookup>();
|
||||
foreach (var l in lookupTypes)
|
||||
{
|
||||
try
|
||||
{
|
||||
var typeInstance = Activator.CreateInstance(l) as ILookup;
|
||||
lookups.Add(typeInstance);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//TODO: Need to fix logging so this doesn't bork if no SQL connection
|
||||
//Log.Add(LogTypes.Error, -1, "Error loading ILookup: " + ex.ToString());
|
||||
}
|
||||
}
|
||||
//set the global
|
||||
_lookups = lookups;
|
||||
}
|
||||
}
|
||||
}
|
||||
return _lookups;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user