diff --git a/src/Umbraco.Core/ObjectResolution/ApplicationEventsResolver.cs b/src/Umbraco.Core/ObjectResolution/ApplicationEventsResolver.cs index dd22c2bc28..880eac9591 100644 --- a/src/Umbraco.Core/ObjectResolution/ApplicationEventsResolver.cs +++ b/src/Umbraco.Core/ObjectResolution/ApplicationEventsResolver.cs @@ -52,6 +52,7 @@ namespace Umbraco.Core.ObjectResolution { if (_orderedAndFiltered == null) { + _resolved = true; _orderedAndFiltered = GetSortedValues().ToList(); OnCollectionResolved(_orderedAndFiltered); } @@ -59,23 +60,33 @@ namespace Umbraco.Core.ObjectResolution } } - /// - /// 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 { get; set; } + /// + /// 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 + { + get { return _filterCollection; } + set + { + if (_resolved) + throw new InvalidOperationException("Cannot set the FilterCollection delegate once the ApplicationEventHandlers are resolved"); - /// - /// 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) + _filterCollection = value; + } + } + + /// + /// 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) return; @@ -142,8 +153,10 @@ namespace Umbraco.Core.ObjectResolution private bool _disposed; private readonly ReaderWriterLockSlim _disposalLocker = new ReaderWriterLockSlim(); + private Action> _filterCollection; + private bool _resolved = false; - /// + /// /// Gets a value indicating whether this instance is disposed. /// ///