Using C#, how do I create instances of classes that implement a generic interface, that inherits from another generic interface using Reflection. I need to get the implementation of BarcodeTestHelper and BarcodeRepository and create instances of them.
My model:
public interface ITestData{}
public class BarcodelData : ITestData
{
public int Id { get; set; }
}
My API:
public interface IBaseTestHelper<T> where T : ITestData {}
public interface IBarcodeTestHelper : IBaseTestHelper<BarcodeTestData>
My implementation:
public class BarcodeTestHelper : TestBaseHelper, IBarcodeTestHelper
{
private readonly IBarcodeRepository<BarcodeTestData> _barcodeRepository;
public BarcodeTestHelper(IBarcodeRepository<BarcodeTestData> barcodeRepository)
{
_barcodeRepository = barcodeRepository;
}
}
public interface IBarcodeRepository<T> : IRepository<BarcodeTestData> where T : ITestData
{
BarcodeTestData SaveBarcode(string xmlBarcode);
}
public class BarcodeRepository : IBarcodeRepository<BarcodeTestData>
{
BarcodeTestData SaveBarcode(string xmlBarcode)
{
do save work
}
}
Aucun commentaire:
Enregistrer un commentaire