WebApp.Start Method Type Parameter

前端 未结 1 1448
春和景丽
春和景丽 2021-01-01 22:44

In setting up my Windows Service application to self host using Owin based on this article:

http://www.asp.net/web-api/overview/hosting-aspnet-web-api/use-owin-to-se

相关标签:
1条回答
  • 2021-01-01 23:20

    The WebApp class uses reflection to get a pointer to the Configuration(IAppBuilder) method then calls it. If the class you provide as the generic type argument does not have a Configuration method with the expected arguments then you get an error at run time.

    I agree that this is not as discoverable as we would like and I am not sure why the original developers implemented it this way rather than adding a where T: IStartup constraint instead. Not only would this make it more discoverable without documentation, but would also have allowed the compiler to check this at compile time.

    The only advantage to this approach is that the OWIN developers can add more methods or methods with different signatures in the future without breaking existing code.

    0 讨论(0)
提交回复
热议问题