structuremap defines 'buildup' method takes already-constructed object , performs setter injection push in configured dependencies object.
does autofac have equivalent method ?
the question referring already-constructed objects (ones not registered in container) correct answer either injectproperties or injectunsetproperties.
the following test demonstrates behaviour
public class testpropertyinjection { public object shouldbeinjectedbyautofac { get; set; } } [fact] public void autofac_can_inject_properties() { var builder = new containerbuilder(); builder.registertype(typeof(object)); var container = builder.build(); var existingobjectnotregisteredincontainer = new testpropertyinjection(); container.injectproperties(existingobjectnotregisteredincontainer); // can use injectunsetproperties set unset properties //container.injectunsetproperties(existingobjectnotregisteredincontainer); assert.notnull(existingobjectnotregisteredincontainer.shouldbeinjectedbyautofac); }
Comments
Post a Comment