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:

  1. istartable interface, provides start , stop methods. lifecycle interfaces provide lifecycle callbacks: start being called right after component instance gets created (after constructor runs)

  2. 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

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -