如何为不同的导入类型配置 StructureMap

发布于 2024-10-07 23:53:34 字数 231 浏览 0 评论 0原文

我当前有 2 种可以导入的文件类型。我有一个 IImportFileAction 类型的接口。然后我有两个类继承这个接口,名为 ImportGPX 和 ImportTCX。 Import GPX 导入 .gpx 文件,ImportTCX 导入 .tcx 文件。我在这两个类的构造函数中传递文件名。我将如何初始化 StructureMap,以便如果文件扩展名是 gpx,则 GetInstance 将返回 ImportGPX,对于 TCX 反之亦然?

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 and 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

街道布景 2024-10-14 23:53:34

看看 Jeremy 关于条件对象构造的帖子。之后您可能会发现这个SO问题作为示例很有用。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文