Injecting custom collection into a component breaks in 8.6.1
Hi,
I am using a custom Collection to register event handlers on publish etc. This was all working in 8.6.0 updated to 8.6.1 today and it is now not booting.
Code:
Collection
public class EventHandlerCollection : BuilderCollectionBase<IEventHandler<IMyInterface>>
{
public IndexingEventHandlerCollection(IEnumerable<IEventHandler<IMyInterface>> items) : base(items)
{
}
}
Builder
public class IEventHandlerCollectionBuilder : SetCollectionBuilderBase<IEventHandlerCollectionBuilder, EventHandlerCollection, IEventHandler<IMyInterface>>
{
protected override IEventHandlerCollectionBuilder This => this;
}
Composers
[ComposeBefore(typeof(ComposerB))]
public class ComposerA : IUserComposer
{
public void Compose(Composition composition)
{
...
composition.WithCollectionBuilder<EventHandlerCollectionBuilder>().Add<IEventHandler<MyClass>>();
...
}
}
public class ComposerB : ComponentComposer<EventComponent>
{
}
Component
public class Component : IComponent
{
private readonly EventHandlerCollection _eventHandlerCollection;
public SearchComponent(EventHandlerCollection eventHandlerCollection)
{
_eventHandlerCollection = eventHandlerCollection;
}
public void Initialize()
{
foreach (var eventHandler in _eventHandlerCollection)
{
ContentService.Unpublished += eventHandler.Unpublished;
ContentService.Trashed += eventHandler.Trashed;
ContentService.Published += eventHandler.Published;
}
}
}
Does anyone have an idea on what I missing or has changed?
Hi Matt
At first glance it seems OK, but with most things a little more context is
needed please to help you out.
What is the error you get at boot?
Does anything in the log files give you an idea whats going wrong?!(I know horrible JSON - use Compact Log Viewer to help)
Glad you found the solution Matt
The logs does help report the order of composers etc and when it fails to boot it normally gives quite a detailed reason.
Also keep in mind ComponentComposer<T> is a normal IComposer, not an IUserComposer, so composing order might be impacted by that (although the ComposeBefore might overrule that).
The IComponent is missing the Terminate method (probably not copy/pasted), but that should be an empty stub (and not throw a NotImplementedException).
Injecting custom collection into a component breaks in 8.6.1
Hi,
I am using a custom Collection to register event handlers on publish etc. This was all working in 8.6.0 updated to 8.6.1 today and it is now not booting.
Code:
Collection
Builder
Composers
Component
Does anyone have an idea on what I missing or has changed?
Hi Matt
At first glance it seems OK, but with most things a little more context is needed please to help you out.
What is the error you get at boot?
Does anything in the log files give you an idea whats going wrong?!(I know horrible JSON - use Compact Log Viewer to help)
Thanks Warren,
Checking through the logs looks like I had my Registers in the wrong order on other related points.
Note to self: Check your logs well :D
Glad you found the solution Matt
The logs does help report the order of composers etc and when it fails to boot it normally gives quite a detailed reason.
Also keep in mind
ComponentComposer<T>
is a normalIComposer
, not anIUserComposer
, so composing order might be impacted by that (although theComposeBefore
might overrule that).The
IComponent
is missing theTerminate
method (probably not copy/pasted), but that should be an empty stub (and not throw aNotImplementedException
).is working on a reply...