yavsc/build/approot/packages/Microsoft.Extensions.CodeGe.../1.0.0-rc1-final/Templates/Startup
Paul Schneider 849aa6f407 nettoyage 8 years ago
..
ReadMe.cshtml nettoyage 8 years ago
Startup.cshtml nettoyage 8 years ago

ReadMe.cshtml

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

@inherits Microsoft.Extensions.CodeGeneration.Templating.RazorTemplateBase
@using System.Linq;
Scaffolding has generated all the files and added the required dependencies.

However the Application's Startup code may required additional changes for things to work end to end.

Add the following namespace usings if not already added:

@{
    var allNamespaces = new SortedSet<string>(StringComparer.Ordinal);
    foreach (var list in Model.StartupList)
    {
        allNamespaces.UnionWith(list.RequiredNamespaces);
    }
    foreach (var namespaceName in allNamespaces)
    {
@:using @namespaceName;
    }
}
Add the following code to the end of Configure method in your Application's Startup class if not already done:

            // Set up application services
            app.UseServices(services =>
            {
@{
    var count = Model.StartupList.Count;
    for (var index = 0; index < count; index++)
    {
        var list = Model.StartupList[index];
        var atleastOneStatement = false;
        foreach (var statement in list.ServiceStatements)
        {
            atleastOneStatement = true;
                @:@statement
        }
        if (atleastOneStatement && (index != count-1))
        {
@:
        }
    }
}            });

@{
    for (var index = 0; index < count; index++)
    {
        var list = Model.StartupList[index];
        var atleastOneStatement = false;
        foreach (var statement in list.UseStatements)
        {
            atleastOneStatement = true;
            @:@statement
        }
        if (atleastOneStatement && (index != count-1))
        {
@:
        }
    }
}