BotSharp/BotSharp.Core/ContextStorage/ContextStorageFactory.cs
2019-03-16 19:55:55 -05:00

29 lines
877 B
C#

using BotSharp.Platform.Abstractions;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace BotSharp.Core.ContextStorage
{
public class ContextStorageFactory<T> : IContextStorageFactory<T>
{
private readonly Func<string, IContextStorage<T>> func;
private readonly IPlatformSettings platformSetting;
public ContextStorageFactory(IPlatformSettings setting, Func<string, IContextStorage<T>> serviceAccessor)
{
this.func = serviceAccessor;
this.platformSetting = setting;
}
public IContextStorage<T> Get()
{
IContextStorage<T> storage = null;
string storageName = this.platformSetting.ContextStorage;
storage = func(storageName);
return storage as IContextStorage<T>;
}
}
}