Update app-parts.md (#5826)

pull/5830/head
MackHog 2018-03-29 15:30:35 +02:00 committed by Luke Latham
parent 1d41e4d1e9
commit dab1669d77
1 changed files with 5 additions and 5 deletions

View File

@ -30,7 +30,7 @@ services.AddMvc()
var assembly = typeof(Startup).GetTypeInfo().Assembly; var assembly = typeof(Startup).GetTypeInfo().Assembly;
var part = new AssemblyPart(assembly); var part = new AssemblyPart(assembly);
services.AddMvc() services.AddMvc()
.ConfigureApplicationPartManager(apm => p.ApplicationParts.Add(part)); .ConfigureApplicationPartManager(apm => apm.ApplicationParts.Add(part));
``` ```
By default MVC will search the dependency tree and find controllers (even in other assemblies). To load an arbitrary assembly (for instance, from a plugin that isn't referenced at compile time), you can use an application part. By default MVC will search the dependency tree and find controllers (even in other assemblies). To load an arbitrary assembly (for instance, from a plugin that isn't referenced at compile time), you can use an application part.
@ -41,9 +41,9 @@ If you have an assembly that contains controllers you don't want to be used, rem
```csharp ```csharp
services.AddMvc() services.AddMvc()
.ConfigureApplicationPartManager(p => .ConfigureApplicationPartManager(apm =>
{ {
var dependentLibrary = p.ApplicationParts var dependentLibrary = apm.ApplicationParts
.FirstOrDefault(part => part.Name == "DependentLibrary"); .FirstOrDefault(part => part.Name == "DependentLibrary");
if (dependentLibrary != null) if (dependentLibrary != null)
@ -80,8 +80,8 @@ The feature provider is added in `Startup`:
```csharp ```csharp
services.AddMvc() services.AddMvc()
.ConfigureApplicationPartManager(p => .ConfigureApplicationPartManager(apm =>
p.FeatureProviders.Add(new GenericControllerFeatureProvider())); apm.FeatureProviders.Add(new GenericControllerFeatureProvider()));
``` ```
By default, the generic controller names used for routing would be of the form *GenericController`1[Widget]* instead of *Widget*. The following attribute is used to modify the name to correspond to the generic type used by the controller: By default, the generic controller names used for routing would be of the form *GenericController`1[Widget]* instead of *Widget*. The following attribute is used to modify the name to correspond to the generic type used by the controller: