Skip to content

Commit 5ceaa2b

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 81692f7 + 196561f commit 5ceaa2b

File tree

9 files changed

+161
-101
lines changed

9 files changed

+161
-101
lines changed

maze/common/common.csproj

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netstandard1.4</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<Compile Include="**\*.cs" />
9+
<EmbeddedResource Include="**\*.resx" />
10+
</ItemGroup>
11+
12+
<ItemGroup>
13+
<PackageReference Include="NETStandard.Library" Version="1.6" />
14+
</ItemGroup>
15+
16+
</Project>

maze/common/maze.cs

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
using System;
2+
3+
namespace CodeAdventure.Maze
4+
{
5+
public class Maze
6+
{
7+
public Maze(int width = 40, int height = 30)
8+
{
9+
Height = height;
10+
Width = width;
11+
_maze = new char[height][];
12+
for (int i = 0; i < height; i++)
13+
{
14+
_maze[i] = new char[width];
15+
}
16+
}
17+
18+
public void Fill(char fillValue)
19+
{
20+
for (int h = 0; h < Height; h++)
21+
{
22+
for (int w = 0; w < Width; w++)
23+
{
24+
_maze[h][w] = fillValue;
25+
}
26+
}
27+
}
28+
29+
public void SetBorder(char borderValue)
30+
{
31+
for (int w = 0; w < Width; w++)
32+
{
33+
_maze[0][w] = borderValue;
34+
_maze[Height - 1][w] = borderValue;
35+
}
36+
37+
for (int h = 1; h < Height - 1; h++)
38+
{
39+
_maze[h][0] = borderValue;
40+
_maze[h][Width - 1] = borderValue;
41+
}
42+
}
43+
44+
public void SetStart(char startValue = 'S',int x = 0, int y = 1)
45+
{
46+
_maze[y][x] = startValue;
47+
}
48+
49+
public void SetEnd(char endValue, int x, int y)
50+
{
51+
_maze[y][x] = endValue;
52+
}
53+
54+
public char GetValue(int x, int y)
55+
{
56+
return _maze[y][x];
57+
}
58+
59+
public int Height { get; }
60+
public int Width { get; }
61+
62+
private char[][] _maze;
63+
}
64+
}

maze/maze.csproj

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>netcoreapp1.0</TargetFramework>
6+
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
7+
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
8+
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
9+
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
10+
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
11+
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
12+
<GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute>
13+
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
14+
<GenerateNeutralResourcesLanguageAttribute>false</GenerateNeutralResourcesLanguageAttribute>
15+
</PropertyGroup>
16+
17+
<ItemGroup>
18+
<Compile Include="mazeSample.cs" />
19+
<EmbeddedResource Include="**\*.resx" />
20+
</ItemGroup>
21+
22+
<ItemGroup>
23+
<PackageReference Include="Microsoft.NETCore.App" Version="1.0.1" />
24+
</ItemGroup>
25+
26+
<ItemGroup>
27+
<ProjectReference Include=".\common\common.csproj" />
28+
</ItemGroup>
29+
30+
</Project>

maze/mazeSample.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
using CodeAdventure.Maze;
3+
4+
class Program
5+
{
6+
static void Main(string[] args)
7+
{
8+
Console.WriteLine("Here is your Maze!");
9+
Maze maze = new Maze();
10+
maze.Fill(' ');
11+
maze.SetBorder('#');
12+
maze.SetStart();
13+
maze.SetEnd('E', maze.Width - 1, maze.Height - 2);
14+
for (int y = 0; y < maze.Height; y++)
15+
{
16+
string row = "";
17+
for (int x = 0; x < maze.Width; x++)
18+
{
19+
//TODO: use string builder
20+
row += maze.GetValue(x, y);
21+
}
22+
Console.WriteLine(row);
23+
}
24+
25+
}
26+
}

web/chores/Program.cs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,21 @@
11
using System.IO;
2+
using Microsoft.AspNetCore;
23
using Microsoft.AspNetCore.Hosting;
3-
using Microsoft.AspNetCore.Builder;
4+
using Microsoft.Extensions.Configuration;
5+
using Microsoft.Extensions.Logging;
46

57
namespace Chores
68
{
79
public class Program
810
{
911
public static void Main(string[] args)
1012
{
11-
var host = new WebHostBuilder()
12-
.UseKestrel( options =>
13-
{
14-
//Configure SSL
15-
options.NoDelay = true;
16-
options.UseHttps("cert.pfx", "testPassword");
17-
options.UseConnectionLogging();
18-
})
19-
.UseUrls("http://localhost:5000", "https://localhost:5001")
20-
.UseContentRoot(Directory.GetCurrentDirectory())
21-
.UseStartup<Startup>()
22-
.Build();
23-
24-
host.Run();
13+
BuildWebHost(args).Run();
2514
}
15+
16+
public static IWebHost BuildWebHost(string[] args) =>
17+
WebHost.CreateDefaultBuilder(args)
18+
.UseStartup<Startup>()
19+
.Build();
2620
}
2721
}

web/chores/Startup.cs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ public void ConfigureServices(IServiceCollection services)
3232
options.UseSqlite(Configuration.GetConnectionString("Chores"));
3333
});
3434
services.AddMvc();
35-
services.AddAuthentication(options => options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme);
3635
}
3736

3837

@@ -68,23 +67,6 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
6867
}
6968
});
7069

71-
app.UseCookieAuthentication(new CookieAuthenticationOptions
72-
{
73-
AutomaticAuthenticate = true,
74-
AutomaticChallenge = true,
75-
LoginPath = new PathString("/login")
76-
});
77-
78-
// See config.json
79-
// https://azure.microsoft.com/en-us/documentation/articles/active-directory-v2-app-registration/
80-
app.UseMicrosoftAccountAuthentication(new MicrosoftAccountOptions
81-
{
82-
DisplayName = "MicrosoftAccount",
83-
ClientId = Configuration["msa:clientid"],
84-
ClientSecret = Configuration["msa:clientsecret"],
85-
SaveTokens = true
86-
});
87-
8870
// Choose an authentication type
8971
app.Map("/login", signoutApp =>
9072
{
@@ -95,7 +77,6 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
9577
{
9678
// By default the client will be redirect back to the URL that issued the challenge (/login?authtype=foo),
9779
// send them to the home page instead (/).
98-
await context.Authentication.ChallengeAsync(authType, new AuthenticationProperties() { RedirectUri = "/" });
9980
return;
10081
}
10182

@@ -161,11 +142,6 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
161142
}
162143

163144
await context.Response.WriteAsync("Tokens:<br>");
164-
165-
await context.Response.WriteAsync("Access Token: " + await context.Authentication.GetTokenAsync("access_token") + "<br>");
166-
await context.Response.WriteAsync("Refresh Token: " + await context.Authentication.GetTokenAsync("refresh_token") + "<br>");
167-
await context.Response.WriteAsync("Token Type: " + await context.Authentication.GetTokenAsync("token_type") + "<br>");
168-
await context.Response.WriteAsync("expires_at: " + await context.Authentication.GetTokenAsync("expires_at") + "<br>");
169145
await context.Response.WriteAsync("<a href=\"/logout\">Logout</a>");
170146
await context.Response.WriteAsync("</body></html>");
171147
});

web/chores/chores.csproj

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp2.0</TargetFramework>
5+
<UserSecretsId>chores-secret-20160514111056</UserSecretsId>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<Folder Include="wwwroot\" />
10+
</ItemGroup>
11+
12+
<ItemGroup>
13+
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0-preview1-final" />
14+
</ItemGroup>
15+
16+
</Project>

web/chores/chores.xproj

Lines changed: 0 additions & 19 deletions
This file was deleted.

web/chores/project.json

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)