开发者

How to configure StructureMap for different Import Types

开发者 https://www.devze.com 2023-01-31 07:06 出处:网络
I have currently 2 file types I can import.I have an interface of type IImportFileAction.Then I have 2 classes that inherit this interface named ImportGPX and ImportTCX.Import GPX imports a .gpx file

I have currently 2 file types I can import. I have an interface of type IImportFileAction. Then I have 2 classes that inherit this interface named ImportGPX and ImportTCX. Import GPX imports a .gpx file a开发者_开发知识库nd ImportTCX imports a .tcx file. I pass the filename in the constructor of these two classes. How would I initialize StructureMap so that if the files extention is gpx the GetInstance will return the ImportGPX and vice versa for TCX?


Take a look at Jeremy's post on conditional object construction. Afterwards you may find this SO question useful as an example.

0

精彩评论

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