dryioc - Override certain implementation when resolving a dependency -


i have read documentation , can't find resolving type , @ same time override of dependencies. easiest illustrate example

public class {     public a(iservicea a, iserviceb b) {}     } // resolve scenarion type =>  {     // type     var = container.resolve<iservicea>();     a.someproperty = "magic";     return container.resolve(type) // todo: how resolve using } 

does make sense? looking like

return container.resolve(type, rule.override.typeof<iservicea>(a)); 

great job dryioc

edit (2016-05-26) question missleading. below complete code example (for prism)

viewmodellocationprovider.setdefaultviewmodelfactory((view, type) => {      var page = view page;      if (page != null)      {                               var navigationservice = container.resolve<inavigationservice>();           ((ipageaware)navigationservice).page = page;           var @override = container.resolve<func<inavigationservice, type>>(); // how           return @override(navigationservice);      }      return container.resolve(type); }); 

resolve func parameter want pass:

var factory = container.resolve<func<iservicea, a>>(); var result = factory(a); 

update:

given runtime type resolve:

type =>  {     // type     var = container.resolve<iservicea>();     a.someproperty = "magic";      // asking required service type, wrapped in func returning object     var factory = container.resolve<func<iservicea, object>>(requiredservicetype: type);     return factory(a); } 

Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -