BililiveRecorder/BililiveRecorder.Core/RoomFactory.cs
2021-02-23 18:03:37 +08:00

25 lines
651 B
C#

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;
}
public IRoom CreateRoom(RoomConfig roomConfig)
{
var scope = this.serviceProvider.CreateScope();
var sp = scope.ServiceProvider;
return ActivatorUtilities.CreateInstance<Room>(sp, scope, roomConfig);
}
}
}