given the following class hierarchy:
class AbstractPanel
{ }
class AbstractComponent : public AbstractPanel
{ }
class Component : public AbstractComponent
{ }
and the following Hypodermic DI Container:
Hypodermic::ContainerBuilder builder;
builder.registerType<Component>( CREATE(new Component()) )->as<Component>()->named<Component>("bkgrd_param_component");
(... and adding it to "di_container")
Depending on the Context, a resolve()-Call looks like this:
di_container->resolveNamed<AbstractComponent>("bkgrd_param_component")
or
di_container->resolveNamed<AbstractPanel>("bkgrd_param_component")
Both calls return a nullptr, although my registered Object is both of type "AbstractPanel" and "AbstractComponent".
How do I have to design this? I can't change the class-hierarchy but want to resolve the Object, depending on its name.
Does anybody have an idea?
Regards, Vandahlen