You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// class Logger : ILoggervarregistration= Lifestyle.Transient.CreateRegistration<ILogger,Logger>(container);// Logger does not implement IPluginvarproducer=new InstanceProducer(typeof(IPlugin), registration);objectinstance= producer.GetInstance();
The returned instance is of type Logger. But this is about the only case where this works. When a decorator is applied to IPlugin, an ugly exception will be thrown when the expression tree is built. Obviously, casting the GetInstance() result to an IPlugin will fail.
A pre-condition check needs to be added to prevent that the InstanceProducer can't be created.
This can actually be a bit tricky, because some parts of the system create Registration instances without or with incorrect ImplementationTypes. Especially the decorator subsystem for uncontrolled collections does this.
The text was updated successfully, but these errors were encountered:
This code compiles and runs:
The returned instance is of type
Logger
. But this is about the only case where this works. When a decorator is applied to IPlugin, an ugly exception will be thrown when the expression tree is built. Obviously, casting the GetInstance() result to anIPlugin
will fail.A pre-condition check needs to be added to prevent that the InstanceProducer can't be created.
This can actually be a bit tricky, because some parts of the system create
Registration
instances without or with incorrectImplementationType
s. Especially the decorator subsystem for uncontrolled collections does this.The text was updated successfully, but these errors were encountered: