BotSharp/BotSharp.Core/AgentStorage/AgentStorageFactory.cs
haiping008 3c7c3c183b add ContextStorageFactory
persist context to file
2018-12-07 16:57:26 -06:00

31 lines
975 B
C#

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.AgentStorage
{
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 IAgentStorage<TAgent> Get()
{
IAgentStorage<TAgent> storage = null;
string storageName = this.platformSetting.AgentStorage;
storage = func(storageName);
return storage as IAgentStorage<TAgent>;
}
}
}