【发布时间】:2014-03-06 18:20:52
【问题描述】:
我有一个接口,想在其中包含一个方法,该方法有一个带参数约束的类。是否有可能以不需要在接口声明中包含约束的方式创建它?
public interface IPlugin
{
void InitializeSession(MBROContext context, Reporter<TEntity, TContext> reporter);
}
TEntity 是一个继承自 IEntity 的类。 TContext 是一个继承自 IDbcontext 的 DbContext。
reporter类的签名如下:
public class Reporter<TEntity, TContext> where TEntity : class, IEntity where TContext : IDbContext, IDisposable, new()
{
private IUnitOfWork uow;
private IRepository<TEntity> entryRepository;
private IService<TEntity> entryService;
public Reporter()
{
this.uow = new UnitOfWork<TContext>();
this.entryRepository = uow.GetRepository<TEntity>();
this.entryService = new Service<TEntity>(this.uow);
}
public void Dispose()
{
throw new NotImplementedException();
}
}
我希望这是有道理的。
【问题讨论】:
标签: c# .net unity-container