我有一个泛型类和这样的通用接口:
public interface IDataService<T> where T: class
{
IEnumerable<T> GetAll();
}
public class DataService<T> : IDataService<T> where T : class
{
public IEnumerable<T> GetAll()
{
return Seed<T>.Initialize();
}
}
public static IEnumerable<T> Initialize()
{
List<T> allCalls = new List<T>();
....
return allCalls;
}
Run Code Online (Sandbox Code Playgroud)
现在在我的StartUp.cs中,我正在连接类和接口
public void ConfigureServices(IServiceCollection services)
{
services.AddTransient(typeof(IDataService<>), typeof(DataService<>));
...
}
Run Code Online (Sandbox Code Playgroud)
当我尝试在我的例如Repository.cs中使用它时,它总是为空.
public class Repository<T> : IRepository<T> where T : class
{
private readonly IDataService<T> _dataService;
public Repository(IDataService<T> dataService)
{
_dataService = dataService;
...
}
...
}
Run Code Online (Sandbox Code Playgroud)
编辑这是请求的存储库接口和类 …
我正在使用Visual Studio Online我用PBI创建了一个项目A,其中包含许多任务.我现在已经创建了一个新项目B,并希望将PBI和任务从项目A移动/复制/迁移到该项目B.我如何实现这一目标.
我对新的Roslyn C#编译器有点困惑.
一开始我假设这个新编译器可以在我的ASP.NET MVC网站中更改C#代码,然后在浏览器中查看这些更改,而无需重建项目/解决方案.
无论如何做更多的阅读,特别是新的信息,我现在更加确定了.
是否可以使用Roslyn在例如控制器类中更改C#代码,而不必构建项目并仍然能够看到更改?