KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Between various Stack Overflow questions and blog posts there is a pretty reasonable amount of documentation on the topic of open generics and StructureMap. Unfortunately, I must be missing something as my attempts at using scan to perform the configuration along with a class implementation that has a "greedy" constructor have yet work. I want StructureMap to grab an instance of the below class via references to its implemented interface. ToCsvService exists in an unreferenced assembly called Infrastructure. IToCsvService exists in a referenced assembly called Core. As you can see ToCsvService has a "greedy" constructor. public class ToCsvService<TSource> : IToCsvService<TSource> { public ToCsvService(ICollection<TSource> collection) { } } I let StructureMap know about ToCsvService via the ConnectImplementationsToTypesClosing method. ObjectFactory.Initialize(cfg => { cfg.Scan(scan => { scan.Assembly("Infrastructure"); scan.WithDefaultConventions(); // even with this call StructureMap cannot use ToCsvService // instance of IToCsvService (though wouldn't expect it to) scan.ConnectImplementationsToTypesClosing (typeof(IToCsvService<>)); }); }); From the ObjectFactory.WhatDoIHave() method it appears that StructureMap is aware of ToCsvService . PluginType Name Description -----------------------------------------------------------------------------------------------------------------------------------------------------------
Tags (comma-separated)
Save Edits
Cancel