BililiveRecorder/BililiveRecorder.Core/RoomFactory.cs

25 lines
691 B
C#
Raw Normal View History

2021-02-23 18:03:37 +08:00
using System;
2021-12-19 21:10:34 +08:00
using BililiveRecorder.Core.Config.V3;
2021-02-23 18:03:37 +08:00
using Microsoft.Extensions.DependencyInjection;
namespace BililiveRecorder.Core
{
internal class RoomFactory : IRoomFactory
2021-02-23 18:03:37 +08:00
{
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
}
}
}