- marked as minor
- edited description
Impossible to register multicast composite component because of recursion
Issue #18
resolved
Following is not possible currently because it will raise ECircularDependencyException:
container.RegisterType<IObserver<TUnit>, TNeedyClass>('needy');
container.RegisterType<IObserver<TUnit>, TAnotherObserver>('another');
container.RegisterType<IObserver<TUnit>, TCompositeObserver<TUnit>>;
where TCompositeObserver<T> has this constructor:
constructor Create(const observers: TArray<IObserver<T>>);
Logically this should work because TCompositeObserver is a registration without name and thus will not be considered when resolving an array of IObserver<T>.
The workaround for now it to manually resolve the array like this:
container.RegisterType<IObserver<TUnit>, TNeedyClass>('needy');
container.RegisterType<IObserver<TUnit>, TAnotherObserver>('another');
container.RegisterType<IObserver<TUnit>, TCompositeObserver<TUnit>>.DelegateTo(
function: TCompositeObserver<TUnit>
begin
Result := TCompositeObserver<TUnit>.Create(container.ResolveAll<IObserver<TUnit>>);
end);
Comments (6)
-
reporter -
reporter - changed status to resolved
fixed issue
#18→ <<cset cf181fb70d89>>
-
reporter - changed milestone to 1.1
-
reporter - changed version to 1.0 (released)
-
reporter - changed version to 1.0 (master)
-
reporter - changed version to 1.0
- Log in to comment