Created
June 27, 2018 10:51
-
-
Save sfmskywalker/19f849a618a33e0c266b5dff2b313c9c to your computer and use it in GitHub Desktop.
Partial Startup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.UseOrchardCore(a => a.Run(async context => | |
{ | |
// ShellSettings provide the tenant's configuration. | |
var shellSettings = context.RequestServices.GetRequiredService<ShellSettings>(); | |
// Read the tenant-specific custom setting. | |
var customSetting = shellSettings.Configuration["CustomSetting"]; | |
// Resolve all registered IMessageProvider services. | |
var messageProviders = context.RequestServices.GetServices<IMessageProvider>(); | |
// Invoke all IMessageProviders. | |
var messages = (await Task.WhenAll(messageProviders.Select(async x => await x.GetMessageAsync()))).ToList(); | |
// Add the custom setting as a message. Alternatively, could have implemented another IMessageProvider that reads the | |
messages.Insert(0, customSetting); | |
// Concatenate all messages. | |
var output = string.Join("\r\n", messages); | |
// Write the output string to the response stream. | |
await context.Response.WriteAsync(output); | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment