Created
October 28, 2011 03:58
-
-
Save shiftkey/1321588 to your computer and use it in GitHub Desktop.
Repro - Open Generics Not Supported in MEF v2 Preview 4?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.ComponentModel.Composition.Hosting; | |
using System.ComponentModel.Composition.Registration; | |
using Microsoft.VisualStudio.TestTools.UnitTesting; | |
namespace System.ComponentModel.Composition | |
{ | |
[TestClass] | |
public class RegistrationBuilderTestBF | |
{ | |
public interface IRepository<out T> { | |
T Get(); | |
} | |
public class SomeModel { } | |
public class Repository<T> : IRepository<T> { | |
public T Get() | |
{ | |
return default(T); | |
} | |
} | |
public class SomeController | |
{ | |
public SomeController(IRepository<SomeModel> someModel) { | |
} | |
} | |
[TestMethod] | |
public void RegistrationBuilder_WithOpenGeneric_ShouldCreateType() | |
{ | |
var rb = new RegistrationBuilder(); | |
rb.ForType<SomeController>().Export(); | |
rb.ForTypesDerivedFrom(typeof(IRepository<>)).Export(); | |
var newCatalog = new AssemblyCatalog(typeof(RegistrationBuilderTestBF).Assembly, rb); | |
var provider = new CatalogExportProvider(newCatalog); | |
Assert.IsNotNull(provider.GetExport<SomeController>()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment