BotSharp/BotSharp.Core/AgentStorageFactory.cs

31 lines
974 B
C#
Raw Normal View History

2018-10-11 13:24:50 +00:00
using BotSharp.Core;
using BotSharp.Platform.Abstraction;
using BotSharp.Platform.Models;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace BotSharp.Core
{
public class AgentStorageFactory<TAgent> : IAgentStorageFactory<TAgent> where TAgent : AgentBase
{
private readonly Func<string, IAgentStorage<TAgent>> func;
private readonly IPlatformSettings platformSetting;
public AgentStorageFactory(IPlatformSettings setting, Func<string, IAgentStorage<TAgent>> serviceAccessor)
{
this.func = serviceAccessor;
this.platformSetting = setting;
}
public async Task<IAgentStorage<TAgent>> Get()
{
IAgentStorage<TAgent> storage = null;
string storageName = this.platformSetting.AgentStorage;
storage = func(storageName);
return storage as IAgentStorage<TAgent>;
}
}
}