2222 * under the License.
2323 */
2424
25+ using Autofac ;
26+ using Autofac . Extensions . DependencyInjection ;
27+
2528using YAF . Core . Extensions ;
29+ using YAF . Core . Hubs ;
30+ using YAF . Core . Middleware ;
31+ using YAF . RazorPages ;
32+ using YAF . UI . Chat ;
33+
34+ var builder = WebApplication . CreateBuilder ( args ) ;
2635
27- namespace YAF . SampleApp ;
36+ builder . Host . UseServiceProviderFactory ( new AutofacServiceProviderFactory ( ) ) ;
2837
29- /// <summary>
30- /// Class Program.
31- /// </summary>
32- public class Program
38+ builder . Host . ConfigureYafLogging ( ) ;
39+
40+ builder . Host . ConfigureContainer < ContainerBuilder > ( containerBuilder =>
3341{
34- /// <summary>
35- /// Defines the entry point of the application.
36- /// </summary>
37- /// <param name="args">
38- /// The arguments.
39- /// </param>
40- /// <returns>
41- /// The <see cref="Task"/>.
42- /// </returns>
43- public static Task Main ( string [ ] args )
44- {
45- var host = Host . CreateDefaultBuilder ( args ) . UseAutofacServiceProviderFactory ( )
46- . ConfigureYafLogging ( )
47- . ConfigureWebHostDefaults ( webHostBuilder =>
48- webHostBuilder . UseStartup < Startup > ( ) ) . Build ( ) ;
49-
50- return host . RunAsync ( ) ;
51- }
52- }
42+ containerBuilder . RegisterYafModules ( ) ;
43+ } ) ;
44+
45+ builder . Services . AddRazorPages ( options =>
46+ {
47+ options . Conventions . AddAreaPageRoute ( "Forums" , "/SiteMap" , "/Sitemap.xml" ) ;
48+ } ) . AddYafRazorPages ( builder . Environment ) ;
49+
50+ builder . Services . AddYafCore ( builder . Configuration ) ;
51+
52+ // only needed for blazor
53+ builder . Services . AddServerSideBlazor ( ) ;
54+
55+ var app = builder . Build ( ) ;
56+
57+ if ( app . Environment . IsDevelopment ( ) )
58+ {
59+ app . UseDeveloperExceptionPage ( ) ;
60+ }
61+ else
62+ {
63+ app . UseExceptionHandler ( "/Forums/Error" ) ;
64+
65+ app . UseHsts ( ) ;
66+ }
67+
68+ app . RegisterAutofac ( ) ;
69+
70+ app . UseAntiXssMiddleware ( ) ;
71+
72+ app . UseStaticFiles ( ) ;
73+
74+ app . UseSession ( ) ;
75+
76+ app . UseYafCore ( BoardContext . Current . ServiceLocator , app . Environment ) ;
77+
78+ app . UseRobotsTxt ( app . Environment ) ;
79+
80+ app . MapRazorPages ( ) ;
81+
82+ // only needed for blazor
83+ app . MapBlazorHub ( ) ;
84+ app . MapFallbackToPage ( "/_Host" ) ;
85+
86+ app . MapAreaControllerRoute (
87+ name : "default" ,
88+ areaName : "Forums" ,
89+ pattern : "{controller=Home}/{action=Index}/{id?}" ) ;
90+
91+ app . MapControllers ( ) ;
92+
93+ app . MapHub < NotificationHub > ( "/NotificationHub" ) ;
94+ app . MapHub < ChatHub > ( "/ChatHub" ) ;
95+
96+ app . MapHub < AllChatHub > ( "/AllChatHub" ) ;
97+
98+ await app . RunAsync ( ) ;
0 commit comments