automapper - Windsor Castle Equivalent of Autofac's IStartable -
i'd able implement in windsor castle container set up:
"for types implement istartable in current assembly register them , run start method them."
similar can using autofac things registering automapper mappings. eg
public class myblahviewmodelmapper : istartable { public void start() { mapper.createmap<myblahentity, myblahviewmodel>(); } }
autofac automagically.... i'm thinking windsor can't me here?
windsor has own istartable
interface. if want windsor register objects , create/run them after you'd use startable facility that.
to clarify, there 2 concepts here:
istartable
interface, providesstart
,stop
methods. lifecycle interfaces provide lifecycle callbacks:start
being called right after component instance gets created (after constructor runs)startable facility, forces
istartable
components instantiated , started after installers have ran.
here's code like:
container.addfacility<startablefacility>(f => f.deferredstart()); container.install(fromassembly.this()); // here startable started
if you're on windsor 3.3 or later can manually trigger startables start (which useful if need setup them)
var flag = new startflag(); container.addfacility<startablefacility>(f => f.deferredstart(flag)); container.install(fromassembly.this()); // whatever else set app needs // when ready, signal flag flag.signal(); // here startable started
Comments
Post a Comment