diff --git a/src/Umbraco.Core/ObjectResolution/ApplicationEventsResolver.cs b/src/Umbraco.Core/ObjectResolution/ApplicationEventsResolver.cs
index 6cb60e2df0..3537d47a00 100644
--- a/src/Umbraco.Core/ObjectResolution/ApplicationEventsResolver.cs
+++ b/src/Umbraco.Core/ObjectResolution/ApplicationEventsResolver.cs
@@ -53,20 +53,28 @@ namespace Umbraco.Core.ObjectResolution
if (_orderedAndFiltered == null)
{
_resolved = true;
- _orderedAndFiltered = GetSortedValues().ToList();
- OnCollectionResolved(_orderedAndFiltered);
+ _orderedAndFiltered = GetSortedValues().ToList();
+
+ //call the callback if one is applied
+ if (FilterCollection != null)
+ {
+ FilterCollection(_orderedAndFiltered);
+ }
}
return _orderedAndFiltered;
}
}
-
- ///
- /// A delegate that can be set in the pre-boot phase in order to filter or re-order the event handler collection
- ///
- ///
- /// This can be set on startup in the pre-boot process in either a custom boot manager or global.asax (UmbracoApplication)
- ///
- public Action> FilterCollection
+
+ ///
+ /// EXPERT: Allow a delegate to be set to filters the event handler list
+ ///
+ ///
+ /// This allows custom logic to execute in order to filter or re-order the event handlers prior to executing.
+ /// Primarily this is used for custom boot sequences where the custom boot loader may need to remove certain startup
+ /// handlers from executing.
+ /// This can be set on startup in the pre-boot process in either a custom boot manager or global.asax (UmbracoApplication)
+ ///
+ public Action> FilterCollection
{
get { return _filterCollection; }
set
@@ -80,41 +88,29 @@ namespace Umbraco.Core.ObjectResolution
}
}
- ///
- /// Allow any filters to be applied to the event handler list
- ///
- ///
- ///
- /// This allows custom logic to execute in order to filter or re-order the event handlers prior to executing,
- /// however this also ensures that any core handlers are executed first to ensure the stabiliy of Umbraco.
- ///
- private void OnCollectionResolved(List handlers)
- {
- if (FilterCollection != null)
- {
- FilterCollection(handlers);
- }
+ ///
+ /// This will get the object weight for the plugin
+ ///
+ ///
+ ///
+ ///
+ /// For event handlers, all Core event handlers that are not attributed will result in a -100 value
+ ///
+ protected override int GetObjectWeight(object o)
+ {
+ var type = o.GetType();
+ var attr = type.GetCustomAttribute(true);
- //find all of the core handlers and their weight, remove them from the main list
- var coreItems = new List>();
- foreach (var handler in handlers.ToArray())
- {
- //Yuck, but not sure what else we can do
- if (
- handler.GetType().Assembly.FullName.StartsWith("Umbraco.", StringComparison.OrdinalIgnoreCase)
- || handler.GetType().Assembly.FullName.StartsWith("Concorde."))
- {
- coreItems.Add(new Tuple(handler, GetObjectWeight(handler)));
- handlers.Remove(handler);
- }
- }
+ if (attr == null &&
+ (o.GetType().Assembly.FullName.StartsWith("Umbraco.", StringComparison.OrdinalIgnoreCase)
+ || o.GetType().Assembly.FullName.StartsWith("Concorde.")))
+ {
+ return -100;
+ }
- //re-add the core handlers to the beginning of the list ordered by their weight
- foreach (var coreHandler in coreItems.OrderBy(x => x.Item2))
- {
- handlers.Insert(0, coreHandler.Item1);
- }
+ return attr == null ? DefaultPluginWeight : attr.Weight;
}
+
///
/// Create instances of all of the legacy startup handlers
diff --git a/src/Umbraco.Core/ObjectResolution/WeightAttribute.cs b/src/Umbraco.Core/ObjectResolution/WeightAttribute.cs
index 35f10a4111..067df5700c 100644
--- a/src/Umbraco.Core/ObjectResolution/WeightAttribute.cs
+++ b/src/Umbraco.Core/ObjectResolution/WeightAttribute.cs
@@ -15,23 +15,11 @@ namespace Umbraco.Core.ObjectResolution
///
/// This internal constructor allows for internal Umbraco products to set a negative number weight
///
- internal WeightAttribute(int weight)
+ public WeightAttribute(int weight)
{
Weight = weight;
}
- ///
- /// Initializes a new instance of the class with a weight.
- ///
- /// The object type weight.
- ///
- /// The weight must be a positive number
- ///
- public WeightAttribute(uint weight)
- {
- Weight = Convert.ToInt32(weight);
- }
-
///
/// Gets or sets the weight of the object type.
///