ChrisCompleteCodeTrunk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
@inherits Microsoft.VisualStudio.Web.CodeGeneration.Templating.RazorTemplateBase
@using System.Collections.Generic
@using System.Linq
using System;
@{
var namespaceSet = new HashSet<string>(
new string[]
{
"Microsoft.AspNetCore.Identity",
"Microsoft.AspNetCore.Identity.UI",
"Microsoft.AspNetCore.Hosting",
"Microsoft.EntityFrameworkCore",
"Microsoft.Extensions.Configuration",
"Microsoft.Extensions.DependencyInjection",
});
var thisNamespace = $"{Model.Namespace}.Areas.Identity";
if (!string.IsNullOrEmpty(Model.UserClassNamespace) && thisNamespace != Model.UserClassNamespace)
{
namespaceSet.Add(Model.UserClassNamespace);
}
else
{
namespaceSet.Add("Microsoft.AspNetCore.Identity.EntityFrameworkCore");
}
if (thisNamespace != Model.DbContextNamespace)
{
namespaceSet.Add(Model.DbContextNamespace);
}
foreach(var name in namespaceSet.OrderBy(n => n))
{
@:using @name;
}
}
[assembly: HostingStartup(typeof(@(thisNamespace).IdentityHostingStartup))]
namespace @(thisNamespace)
{
public class IdentityHostingStartup : IHostingStartup
{
public void Configure(IWebHostBuilder builder)
{
@{
@: builder.ConfigureServices((context, services) => {
if (!Model.IsUsingExistingDbContext)
{
if (Model.UseSQLite)
{
@: services.AddDbContext<@Model.DbContextClass>(options =>
@: options.UseSqlite(
@: context.Configuration.GetConnectionString("@(Model.DbContextClass)Connection")));
} // End if Model.UseSQLite
else
{
@: services.AddDbContext<@Model.DbContextClass>(options =>
@: options.UseSqlServer(
@: context.Configuration.GetConnectionString("@(Model.DbContextClass)Connection")));
} // End else
@:
@: services.AddDefaultIdentity<@(Model.UserClass)>()
@: .AddEntityFrameworkStores<@Model.DbContextClass>();
} // End Model.IsUsingExstingDbContext
@: });
}
}
}
}
|
Revision |
Author |
Commited |
Message |
1
|
BBDSCHRIS
|
Wed 22 Aug, 2018 20:08:03 +0000 |
|