wpf - Will a DI-Container help this situation -


i writing document editor of sorts. application written in wpf , needs able handle multiple documents within same process. each document has own editor window own ribbon (kinda way word it).

i use di patterns in application, f.ex. "savemanager" class injected document supposed save. container can't create whole object graph @ application start up, because user may choose open or create new document @ later time. "normal" way handle this, use abstract factory, means need factory every class operates on document. i'm expecting lot of classes need reference document , don't want jump through hoops sake of di. there way let container manage documents life-time, handing out right document instance @ right time.

best regards,
terje

i suggest go this:

  1. make base class somesort of bootstrap , builder environment
  2. put same on documents except specifics
  3. create concrete classes implement specifics of particular documents
  4. use di on base class common references injected on build
  5. use interfaces specific references on specific classes like:

    void myclass(iresource resource);

  6. inherit resource on other classes , resolve using generics or typecasting on concrete classes


Comments