2021-02-23 18:03:37 +08:00
|
|
|
using System;
|
|
|
|
using BililiveRecorder.Core.Config.V2;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
|
|
namespace BililiveRecorder.Core
|
|
|
|
{
|
|
|
|
public class RoomFactory : IRoomFactory
|
|
|
|
{
|
|
|
|
private readonly IServiceProvider serviceProvider;
|
|
|
|
|
|
|
|
public RoomFactory(IServiceProvider serviceProvider)
|
|
|
|
{
|
|
|
|
this.serviceProvider = serviceProvider;
|
|
|
|
}
|
|
|
|
|
2021-04-30 19:35:15 +08:00
|
|
|
public IRoom CreateRoom(RoomConfig roomConfig, int initDelayFactor)
|
2021-02-23 18:03:37 +08:00
|
|
|
{
|
|
|
|
var scope = this.serviceProvider.CreateScope();
|
|
|
|
var sp = scope.ServiceProvider;
|
|
|
|
|
2021-04-30 19:35:15 +08:00
|
|
|
return ActivatorUtilities.CreateInstance<Room>(sp, scope, roomConfig, initDelayFactor);
|
2021-02-23 18:03:37 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|