Any idea how I can tell AutoMapper to resolve a TypeConverter constructor argument using StructureMap?
ie. We have this:
private class StringIdToContentProviderConverter : TypeConverter<string, ContentProvider> {
private readonly IContentProviderRepository _repository;
public StringIdToContentProviderConverter(IContentProviderRepository repository) {
_repository = repository;
}
public StringIdToContentProviderConverter() {
_repository = ObjectFactory.GetInstance<IContentProviderRepository>();
}
protected override ContentProvider ConvertCore(string contentProviderId) {
return _repository.Get(new Guid(contentProviderId));
}
}
And in the AutoMap registration:
Mapper.CreateMap<Guid, ContentProvider>().ConvertUsing<GuidToContentProviderConverter>();
However, I don't like the idea of hardwiring an ObjectFactory.GetInstance in my constructor for the converter. Any ideas how I can tell AutoMapper how to resolve my IContentProviderRepository?
Or ideas to other approaches for using Automapper to hydrate domain objects from viewmodel ID's using a repository?