开发者

Castle Windsor: Find an implementing assembly and used it

How do I tell castle to pick up an interface implementation from the assemblies in the executing directory.

E.g.

How do I tell castle to find an implementation for ILog and th开发者_运维百科en If I drop log4net among the assemblies in the executing directory, it should pick it and use it. Tomorrow if I decide to change log4net to Nlog it should pick up Nlog to log (both obviously should implement ILog)


You generally should not be so implicit. What if more than one impl is provided? What if you accidentally drop something you didn't intend to?

Having said that, you should use either config file to explicitly tell Windsor in XML which type fulfills your service, or use Binsor if you want more flexibility. There's no magical method in the code "for this service pick whatever implementation there is in any assembly in this folder" and it's very unlikely there will ever be.

And for the specific scenario of loggers, you can use Windsor's Logging facility.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜