Я работаю в сигнальном ядре asp.net под ядром asp.net 2.2, я хочу внедрить зависимость в конструктор концентратора, как я могу это сделать?
Я сделал это универсальным, чтобы передать параметр конструктору.
My Hub:
public class IntegratedHUB : Hub<IIntegratedHubClient>
{
private readonly AuthorizeConnection _authorizeConnection = new AuthorizeConnection();
private readonly ISignalRIdentity _signalRIdentity;
private readonly IVideoService _videoService;
public IntegratedHUB(ISignalRIdentity signalrIdentity, IVideoService videoService)
{
_signalRIdentity = signalrIdentity;
_videoService = videoService;
}
}
Мой класс запуска
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
var _unitofWork = new UnitOfWork(new DbFactory());
var _SignalrIdentity = new SignalRIdentity(_unitofWork, new UnitOfWork(new DbFactory()));
var _videoService = new VideoService(_unitofWork, new UnitOfWork(new DbFactory()));
services.AddCors(options =>
{
options.AddPolicy("CorsPolicy",
builder => builder.SetIsOriginAllowed((host) => true)/*WithOrigins("https://localhost:44381")*/
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials());
});
services.AddTransient<IntegratedHUB, IntegratedHUB>(); // how i change it?
services.AddSignalR();
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseCors("CorsPolicy");
app.UseSignalR(routes =>
{
routes.MapHub<IntegratedHUB>("/integratedHUB");
});
app.UseHttpsRedirection();
app.UseMvc();
}
Как я могу внедрить зависимость в конструктор хаба?