Get instance conditionally in StructureMap

I have an IFileSystemStructureEvaluator interface with two specific implementations: NtfsFileSystemStructureEvaluator and FtpFileSystemStructureEvaluator.

I want to be able to request the appropriate IFileSystemStructureEvaluator depending on whether the Uri that is passed to the constructor is an FTP-uri uri file.

How can I achieve this in StructureMap?

thanks

+6
c # inversion-of-control structuremap
source share
1 answer

You should check out the construction notice for Jeremy Miller. This allows you to use some conditional checks when deciding what you get as an instance. This seems like a solution to your problem.

http://codebetter.com/blogs/jeremy.miller/archive/2009/01/18/conditional-object-construction-in-structuremap-ie-fun-with-lambdas.aspx

+3
source share

All Articles