|
1 |
| -// ------------------------------------------------------------------------ |
| 1 | +// ------------------------------------------------------------------------ |
2 | 2 | // Copyright 2021 The Dapr Authors
|
3 | 3 | // Licensed under the Apache License, Version 2.0 (the "License");
|
4 | 4 | // you may not use this file except in compliance with the License.
|
|
11 | 11 | // limitations under the License.
|
12 | 12 | // ------------------------------------------------------------------------
|
13 | 13 |
|
14 |
| -namespace DaprDemoActor |
| 14 | +using DaprDemoActor; |
| 15 | +using Microsoft.AspNetCore.Builder; |
| 16 | +using Microsoft.Extensions.DependencyInjection; |
| 17 | +using Microsoft.Extensions.Hosting; |
| 18 | + |
| 19 | +var builder = WebApplication.CreateBuilder(args); |
| 20 | + |
| 21 | +builder.Services.AddSingleton<BankService>(); |
| 22 | +builder.Services.AddActors(options => |
15 | 23 | {
|
16 |
| - using Microsoft.AspNetCore.Hosting; |
17 |
| - using Microsoft.Extensions.Hosting; |
| 24 | + options.Actors.RegisterActor<DemoActor>(); |
| 25 | +}); |
18 | 26 |
|
19 |
| - public class Program |
20 |
| - { |
21 |
| - public static void Main(string[] args) |
22 |
| - { |
23 |
| - CreateHostBuilder(args).Build().Run(); |
24 |
| - } |
| 27 | +var app = builder.Build(); |
25 | 28 |
|
26 |
| - public static IHostBuilder CreateHostBuilder(string[] args) => |
27 |
| - Host.CreateDefaultBuilder(args) |
28 |
| - .ConfigureWebHostDefaults(webBuilder => |
29 |
| - { |
30 |
| - webBuilder.UseStartup<Startup>(); |
31 |
| - }); |
32 |
| - } |
| 29 | +if (app.Environment.IsDevelopment()) |
| 30 | +{ |
| 31 | + app.UseDeveloperExceptionPage(); |
33 | 32 | }
|
| 33 | +else |
| 34 | +{ |
| 35 | + app.UseHsts(); |
| 36 | +} |
| 37 | + |
| 38 | +app.UseRouting(); |
| 39 | +app.MapActorsHandlers(); |
| 40 | + |
| 41 | +await app.RunAsync(); |
0 commit comments