Skip to content

Commit

Permalink
all: apply code style to recent changes
Browse files Browse the repository at this point in the history
  • Loading branch information
miltador committed Mar 7, 2017
1 parent 59d2be9 commit cd9a942
Show file tree
Hide file tree
Showing 21 changed files with 1,108 additions and 1,132 deletions.
10 changes: 5 additions & 5 deletions NuGet.Config
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>

<configuration>
<packageSources>
<clear />
<add key="NuGet" value="https://nuget.org/api/v2/" />
</packageSources>
</configuration>
<packageSources>
<clear />
<add key="NuGet" value="https://nuget.org/api/v2/" />
</packageSources>
</configuration>
46 changes: 23 additions & 23 deletions samples/IdentitySample.Mvc/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public class DynamoDbSettings
{
public string ServiceUrl { get; set; }
public string UsersTableName { get; set; }
public string RolesTableName { get; set; }
public string RoleUsersTableName { get; set; }
public string RolesTableName { get; set; }
public string RoleUsersTableName { get; set; }
}

public class Startup
Expand Down Expand Up @@ -59,15 +59,15 @@ public Startup(IHostingEnvironment env)
public void ConfigureServices(IServiceCollection services)
{
services.Configure<DynamoDbSettings>(Configuration.GetSection("DynamoDB"));
services.AddSingleton<DynamoRoleUsersStore<DynamoIdentityRole, DynamoIdentityUser>>();
services.AddSingleton<IUserStore<DynamoIdentityUser>>(sp =>
{
var roleUsersStore = sp.GetService<DynamoRoleUsersStore<DynamoIdentityRole, DynamoIdentityUser>>();
return new DynamoUserStore<DynamoIdentityUser, DynamoIdentityRole>(roleUsersStore);
});
services.AddSingleton<IRoleClaimStore<DynamoIdentityRole>>(sp => new DynamoRoleStore<DynamoIdentityRole>());

services.AddSingleton<DynamoRoleUsersStore<DynamoIdentityRole, DynamoIdentityUser>>();
services.AddSingleton<IUserStore<DynamoIdentityUser>>(sp =>
{
var roleUsersStore = sp.GetService<DynamoRoleUsersStore<DynamoIdentityRole, DynamoIdentityUser>>();
return new DynamoUserStore<DynamoIdentityUser, DynamoIdentityRole>(roleUsersStore);
});
services.AddSingleton<IRoleClaimStore<DynamoIdentityRole>>(sp => new DynamoRoleStore<DynamoIdentityRole>());

services.Configure<IdentityOptions>(options =>
{
var dataProtectionPath = Path.Combine(_env.WebRootPath, "identity-artifacts");
Expand Down Expand Up @@ -161,18 +161,18 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
: new AmazonDynamoDBClient();
var context = new DynamoDBContext(client);

var userStore = app.ApplicationServices
.GetService<IUserStore<DynamoIdentityUser>>()
as DynamoUserStore<DynamoIdentityUser, DynamoIdentityRole>;
var roleStore = app.ApplicationServices
.GetService<IRoleClaimStore<DynamoIdentityRole>>()
as DynamoRoleStore<DynamoIdentityRole>;
var roleUsersStore = app.ApplicationServices
.GetService<DynamoRoleUsersStore<DynamoIdentityRole, DynamoIdentityUser>>();

userStore.EnsureInitializedAsync(client, context, options.Value.UsersTableName).Wait();
roleStore.EnsureInitializedAsync(client, context, options.Value.RolesTableName).Wait();
roleUsersStore.EnsureInitializedAsync(client, context, options.Value.RoleUsersTableName).Wait();
var userStore = app.ApplicationServices
.GetService<IUserStore<DynamoIdentityUser>>()
as DynamoUserStore<DynamoIdentityUser, DynamoIdentityRole>;
var roleStore = app.ApplicationServices
.GetService<IRoleClaimStore<DynamoIdentityRole>>()
as DynamoRoleStore<DynamoIdentityRole>;
var roleUsersStore = app.ApplicationServices
.GetService<DynamoRoleUsersStore<DynamoIdentityRole, DynamoIdentityUser>>();

userStore.EnsureInitializedAsync(client, context, options.Value.UsersTableName).Wait();
roleStore.EnsureInitializedAsync(client, context, options.Value.RolesTableName).Wait();
roleUsersStore.EnsureInitializedAsync(client, context, options.Value.RoleUsersTableName).Wait();
}

private void AddDefaultTokenProviders(IServiceCollection services)
Expand Down
18 changes: 9 additions & 9 deletions samples/IdentitySample.Mvc/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
"ServiceUrl": "http://localhost:8000",
"UsersTableName": "users",
"RolesTableName": "roles",
"RoleUsersTableName": "roleUsers"
"RoleUsersTableName": "roleUsers"
},
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
}
8 changes: 4 additions & 4 deletions samples/IdentitySample.Mvc/web.Debug.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!--
<!--
In the example below, the "SetAttributes" transform will change the value of
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
finds an attribute "name" that has a value of "MyDB".
Expand All @@ -14,8 +14,8 @@
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
-->
<system.web>
<!--
<system.web>
<!--
In the example below, the "Replace" transform will replace the entire
<customErrors> section of your web.config file.
Note that because there is only one customErrors section under the
Expand All @@ -26,5 +26,5 @@
<error statusCode="500" redirect="InternalError.htm"/>
</customErrors>
-->
</system.web>
</system.web>
</configuration>
10 changes: 5 additions & 5 deletions samples/IdentitySample.Mvc/web.Release.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!--
<!--
In the example below, the "SetAttributes" transform will change the value of
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
finds an attribute "name" that has a value of "MyDB".
Expand All @@ -14,9 +14,9 @@
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
-->
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
<!--
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
<!--
In the example below, the "Replace" transform will replace the entire
<customErrors> section of your web.config file.
Note that because there is only one customErrors section under the
Expand All @@ -27,5 +27,5 @@
<error statusCode="500" redirect="InternalError.htm"/>
</customErrors>
-->
</system.web>
</system.web>
</configuration>
14 changes: 7 additions & 7 deletions samples/IdentitySample.Mvc/web.config
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0"?>

<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false"
stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" />
</system.webServer>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false"
stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" />
</system.webServer>
</configuration>
8 changes: 4 additions & 4 deletions src/AspNetCore.Identity.DynamoDB/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
internal static class Constants
{
public const string DefaultTableName = "users";
public const string DefaultRolesTableName = "roles";
public const string DefaultRoleClaimsTableName = "roleClaims";
public const string DefaultRoleUsersTableName = "roleUsers";
}
public const string DefaultRolesTableName = "roles";
public const string DefaultRoleClaimsTableName = "roleClaims";
public const string DefaultRoleUsersTableName = "roleUsers";
}
}
104 changes: 51 additions & 53 deletions src/AspNetCore.Identity.DynamoDB/DynamoDBBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,66 +1,64 @@
using Microsoft.AspNetCore.Identity;
using System;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Text;

namespace AspNetCore.Identity.DynamoDB
{
public class DynamoDBIdentityBuilder<TUser,TRole>
where TUser: DynamoIdentityUser
where TRole: DynamoIdentityRole
{
public IServiceCollection Services { get; set; }
public Type UserType { get; set; }
public Type RoleType { get; set; }
public class DynamoDBIdentityBuilder<TUser, TRole>
where TUser : DynamoIdentityUser
where TRole : DynamoIdentityRole
{
public DynamoDBIdentityBuilder(IServiceCollection services)
{
Services = services;
UserType = typeof(TUser);
RoleType = typeof(TRole);
}

public DynamoDBIdentityBuilder(IServiceCollection services)
{
Services = services;
UserType = typeof(TUser);
RoleType = typeof(TRole);
}
public IServiceCollection Services { get; set; }
public Type UserType { get; set; }
public Type RoleType { get; set; }

private DynamoDBIdentityBuilder<TUser,TRole> AddScoped(Type serviceType, Type concreteType)
{
Services.AddScoped(serviceType, concreteType);
return this;
}
private DynamoDBIdentityBuilder<TUser, TRole> AddScoped(Type serviceType, Type concreteType)
{
Services.AddScoped(serviceType, concreteType);
return this;
}

private DynamoDBIdentityBuilder<TUser,TRole> AddSingleton(Type serviceType, Type concreteType)
{
Services.AddSingleton(serviceType, concreteType);
return this;
}
private DynamoDBIdentityBuilder<TUser, TRole> AddSingleton(Type serviceType, Type concreteType)
{
Services.AddSingleton(serviceType, concreteType);
return this;
}

public DynamoDBIdentityBuilder<TUser,TRole> AddUserStore<T>() where T: class
{
return AddSingleton(typeof(IUserStore<>).MakeGenericType(UserType), typeof(T));
}
public DynamoDBIdentityBuilder<TUser, TRole> AddUserStore<T>() where T : class
{
return AddSingleton(typeof(IUserStore<>).MakeGenericType(UserType), typeof(T));
}

public DynamoDBIdentityBuilder<TUser, TRole> AddUserStore()
{
return AddUserStore<DynamoUserStore<TUser, TRole>>();
}
public DynamoDBIdentityBuilder<TUser, TRole> AddUserStore()
{
return AddUserStore<DynamoUserStore<TUser, TRole>>();
}

public DynamoDBIdentityBuilder<TUser, TRole> AddRoleStore<T>() where T : class
{
return AddSingleton(typeof(IRoleClaimStore<>).MakeGenericType(RoleType), typeof(T));
}
public DynamoDBIdentityBuilder<TUser, TRole> AddRoleStore<T>() where T : class
{
return AddSingleton(typeof(IRoleClaimStore<>).MakeGenericType(RoleType), typeof(T));
}

public DynamoDBIdentityBuilder<TUser, TRole> AddRoleStore()
{
return AddRoleStore<DynamoRoleStore<TRole>>();
}
public DynamoDBIdentityBuilder<TUser, TRole> AddRoleStore()
{
return AddRoleStore<DynamoRoleStore<TRole>>();
}

public DynamoDBIdentityBuilder<TUser, TRole> AddRoleUsersStore<T>() where T : class
{
return AddSingleton(typeof(T), typeof(T));
}
public DynamoDBIdentityBuilder<TUser, TRole> AddRoleUsersStore<T>() where T : class
{
return AddSingleton(typeof(T), typeof(T));
}

public DynamoDBIdentityBuilder<TUser, TRole> AddRoleUsersStore()
{
return AddRoleUsersStore<DynamoRoleUsersStore<TRole, TUser>>();
}
}
}
public DynamoDBIdentityBuilder<TUser, TRole> AddRoleUsersStore()
{
return AddRoleUsersStore<DynamoRoleUsersStore<TRole, TUser>>();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Extensions.DependencyInjection;

namespace AspNetCore.Identity.DynamoDB
{
public static class DynamoDBServiceCollectionExtensions
{
public static DynamoDBIdentityBuilder<TUser,TRole> AddDynamoDBIdentity<TUser, TRole>(this IServiceCollection services)
where TUser: DynamoIdentityUser
where TRole: DynamoIdentityRole
{
return new DynamoDBIdentityBuilder<TUser,TRole>(services);
}
}
}
public static class DynamoDBServiceCollectionExtensions
{
public static DynamoDBIdentityBuilder<TUser, TRole> AddDynamoDBIdentity<TUser, TRole>(this IServiceCollection services)
where TUser : DynamoIdentityUser
where TRole : DynamoIdentityRole
{
return new DynamoDBIdentityBuilder<TUser, TRole>(services);
}
}
}
Loading

0 comments on commit cd9a942

Please sign in to comment.