Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Partial Startup
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
You can’t perform that action at this time.