public override void Configure(IFunctionsHostBuilder builder) { builder.Services .AddSingleton <Settings>() .AddSingleton <LineBotApp>(s => new LineBotApp(LineMessagingClient.Create(s.GetService <Settings>().ChannelAccessToken), s.GetService <Settings>())); }
public override void Configure(IFunctionsHostBuilder builder) { var config = new ConfigurationBuilder() .AddJsonFile("local.settings.json", true) .AddEnvironmentVariables() .Build(); var settings = config.GetSection(nameof(LineBotSettings)).Get <LineBotSettings>(); builder.Services .AddSingleton(settings) .AddSingleton <ILineMessagingClient>(_ => LineMessagingClient.Create(settings.ChannelAccessToken)) .AddSingleton <IWebhookApplication, LineBotApp>(); }
public static IServiceCollection AddBot <TBotApplication>(this IServiceCollection services) where TBotApplication : BotApplication { var config = GetConfig(); var lineSettings = config.GetSection(nameof(LineMessagingApiSettings)).Get <LineMessagingApiSettings>(); return(services .Configure <DurableClientOptions>(options => { options.ConnectionName = "DurableManagementStorage"; options.TaskHub = Environment.GetEnvironmentVariable("TaskHubName"); options.IsExternalClient = true; }) .AddDurableClientFactory() .AddSingleton(lineSettings) .AddSingleton <ILineMessagingClient>(_ => LineMessagingClient.Create(lineSettings.ChannelAccessToken)) .AddScoped <BotApplication, TBotApplication>()); }
public override void Configure(IFunctionsHostBuilder builder) { builder.Services .AddClova <ILineMessageableClova, KatsuzetsuClova>() .AddSingleton <ILineMessagingClient, LineMessagingClient>(_ => LineMessagingClient.Create(Keys.token)); }
public override void Configure(IFunctionsHostBuilder builder) { builder.Services .AddSingleton <ILineMessagingClient>(_ => LineMessagingClient.Create(Environment.GetEnvironmentVariable("ChannelAccessToken"))) .AddTransient <EnqBotApp>(s => new EnqBotApp(s.GetService <ILineMessagingClient>(), Environment.GetEnvironmentVariable("ChannelSecret"))); }