예제 #1
0
 public override void Configure(IFunctionsHostBuilder builder)
 {
     builder.Services
     .AddSingleton <Settings>()
     .AddSingleton <LineBotApp>(s =>
                                new LineBotApp(LineMessagingClient.Create(s.GetService <Settings>().ChannelAccessToken), s.GetService <Settings>()));
 }
예제 #2
0
        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>();
        }
예제 #3
0
        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>());
        }
예제 #4
0
 public override void Configure(IFunctionsHostBuilder builder)
 {
     builder.Services
     .AddClova <ILineMessageableClova, KatsuzetsuClova>()
     .AddSingleton <ILineMessagingClient, LineMessagingClient>(_ => LineMessagingClient.Create(Keys.token));
 }
예제 #5
0
 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")));
 }