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;
|
|
|
|
|
|
|
2018-10-12 02:42:56 +00:00
|
|
|
|
namespace BotSharp.Core.AgentStorage
|
2018-10-11 13:24:50 +00:00
|
|
|
|
{
|
|
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-12-07 22:57:26 +00:00
|
|
|
|
public IAgentStorage<TAgent> Get()
|
2018-10-11 13:24:50 +00:00
|
|
|
|
{
|
|
|
|
|
|
IAgentStorage<TAgent> storage = null;
|
|
|
|
|
|
string storageName = this.platformSetting.AgentStorage;
|
|
|
|
|
|
storage = func(storageName);
|
|
|
|
|
|
return storage as IAgentStorage<TAgent>;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|