From 074a09afb42bd2d282fa94b38676622dc9e421fa Mon Sep 17 00:00:00 2001 From: Robert Wagner Date: Mon, 17 Jul 2017 16:35:21 +1000 Subject: [PATCH] Added sample project --- HighestCommon/.gitignore | 70 +++++++++++++++++++ .../Controllers/CalculateController.cs | 24 +++++++ HighestCommon/HighestCommon.csproj | 20 ++++++ HighestCommon/HighestCommon.sln | 22 ++++++ HighestCommon/Program.cs | 26 +++++++ HighestCommon/Properties/launchSettings.json | 29 ++++++++ HighestCommon/Startup.cs | 43 ++++++++++++ HighestCommon/appsettings.Development.json | 10 +++ HighestCommon/appsettings.json | 8 +++ 9 files changed, 252 insertions(+) create mode 100644 HighestCommon/.gitignore create mode 100644 HighestCommon/Controllers/CalculateController.cs create mode 100644 HighestCommon/HighestCommon.csproj create mode 100644 HighestCommon/HighestCommon.sln create mode 100644 HighestCommon/Program.cs create mode 100644 HighestCommon/Properties/launchSettings.json create mode 100644 HighestCommon/Startup.cs create mode 100644 HighestCommon/appsettings.Development.json create mode 100644 HighestCommon/appsettings.json diff --git a/HighestCommon/.gitignore b/HighestCommon/.gitignore new file mode 100644 index 0000000..3ee7afb --- /dev/null +++ b/HighestCommon/.gitignore @@ -0,0 +1,70 @@ +*.*scc +*.FileListAbsolute.txt +*.aps +*.bak +*.[Cc]ache +*.clw +*.eto +*.fb6lck +*.fbl6 +*.fbpInf +*.ilk +*.lib +*.log +*.ncb +*.nlb +*.obj +*.patch +*.pch +*.pdb +*.plg +*.[Pp]ublish.xml +*.rdl.data +*.sbr +*.scc +*.sig +*.sqlsuo +*.suo +*.svclog +*.tlb +*.tlh +*.tli +*.tmp +*.user +*.vshost.* +*DXCore.Solution +*_i.c +*_p.c +Ankh.Load +Backup*/ +CVS/ +PrecompiledWeb/ +UpgradeLog*.* +[Bb]in/ +[Dd]ebug/ +[Oo]bj/ +[Rr]elease/ +[Tt]humbs.db +_UpgradeReport_Files +_[Rr]e[Ss]harper.*/ +hgignore[.-]* +ignore[.-]* +svnignore[.-]* +lint.db +build +tools/TestResult.xml +*.ReSharper +source/packages +source/OctopusTools.v2.ncrunchsolution +*.orig +*.userprefs +*.lock.json +.vs +.vscode +/tools/ +/artifacts/ +/publish/ +TestResult.xml +TestResults/ +*.received.* +.idea/ diff --git a/HighestCommon/Controllers/CalculateController.cs b/HighestCommon/Controllers/CalculateController.cs new file mode 100644 index 0000000..0abf8ae --- /dev/null +++ b/HighestCommon/Controllers/CalculateController.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; + +namespace HighestCommon.Controllers +{ + [Route("/")] + public class CalculateController : Controller + { + [HttpGet("{a}/{b}")] + public int Get(int a, int b) + { + var max = Math.Min(a, b); + for (int x = max; x > 0; x--) + if (a % x == 0 && b % x == 0) + return x; + + return 0; + } + + } +} diff --git a/HighestCommon/HighestCommon.csproj b/HighestCommon/HighestCommon.csproj new file mode 100644 index 0000000..9f65645 --- /dev/null +++ b/HighestCommon/HighestCommon.csproj @@ -0,0 +1,20 @@ + + + + netcoreapp1.1 + + + + + + + + + + + + + + + + diff --git a/HighestCommon/HighestCommon.sln b/HighestCommon/HighestCommon.sln new file mode 100644 index 0000000..4cc14b3 --- /dev/null +++ b/HighestCommon/HighestCommon.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26430.6 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HighestCommon", "HighestCommon.csproj", "{8EFB664D-794A-4027-8C81-C6D56420DB07}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8EFB664D-794A-4027-8C81-C6D56420DB07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8EFB664D-794A-4027-8C81-C6D56420DB07}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8EFB664D-794A-4027-8C81-C6D56420DB07}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8EFB664D-794A-4027-8C81-C6D56420DB07}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/HighestCommon/Program.cs b/HighestCommon/Program.cs new file mode 100644 index 0000000..3c1aaa8 --- /dev/null +++ b/HighestCommon/Program.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; + +namespace HighestCommon +{ + public class Program + { + public static void Main(string[] args) + { + var host = new WebHostBuilder() + .UseKestrel() + .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIISIntegration() + .UseStartup() + .UseApplicationInsights() + .Build(); + + host.Run(); + } + } +} diff --git a/HighestCommon/Properties/launchSettings.json b/HighestCommon/Properties/launchSettings.json new file mode 100644 index 0000000..92fbe93 --- /dev/null +++ b/HighestCommon/Properties/launchSettings.json @@ -0,0 +1,29 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:63158/", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "api/values", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "HighestCommon": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "api/values", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "http://localhost:63159" + } + } +} diff --git a/HighestCommon/Startup.cs b/HighestCommon/Startup.cs new file mode 100644 index 0000000..73a8ff9 --- /dev/null +++ b/HighestCommon/Startup.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; + +namespace HighestCommon +{ + public class Startup + { + public Startup(IHostingEnvironment env) + { + var builder = new ConfigurationBuilder() + .SetBasePath(env.ContentRootPath) + .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) + .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true) + .AddEnvironmentVariables(); + Configuration = builder.Build(); + } + + public IConfigurationRoot Configuration { get; } + + // This method gets called by the runtime. Use this method to add services to the container. + public void ConfigureServices(IServiceCollection services) + { + // Add framework services. + services.AddMvc(); + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) + { + loggerFactory.AddConsole(Configuration.GetSection("Logging")); + loggerFactory.AddDebug(); + + app.UseMvc(); + } + } +} diff --git a/HighestCommon/appsettings.Development.json b/HighestCommon/appsettings.Development.json new file mode 100644 index 0000000..fa8ce71 --- /dev/null +++ b/HighestCommon/appsettings.Development.json @@ -0,0 +1,10 @@ +{ + "Logging": { + "IncludeScopes": false, + "LogLevel": { + "Default": "Debug", + "System": "Information", + "Microsoft": "Information" + } + } +} diff --git a/HighestCommon/appsettings.json b/HighestCommon/appsettings.json new file mode 100644 index 0000000..5fff67b --- /dev/null +++ b/HighestCommon/appsettings.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "IncludeScopes": false, + "LogLevel": { + "Default": "Warning" + } + } +}