From fd0e699918f9932856afce8b72b75842640c61ee Mon Sep 17 00:00:00 2001 From: Manuel Rauber Date: Thu, 1 Oct 2015 11:52:46 +0200 Subject: [PATCH] Look at my API, my API will be amazing! --- .gitattributes | 63 +++++ .gitignore | 241 ++++++++++++++++++ api/BoardGame/BoardGame.Api.sln | 28 ++ .../BoardGame.Api/BoardGame.Api.csproj | 94 +++++++ .../BoardGame.Api/Properties/AssemblyInfo.cs | 36 +++ api/BoardGame/BoardGame.Api/Startup.cs | 39 +++ api/BoardGame/BoardGame.Api/packages.config | 13 + api/BoardGame/BoardGame.Host/App.config | 6 + .../BoardGame.Host/BoardGame.Host.csproj | 103 ++++++++ api/BoardGame/BoardGame.Host/Program.cs | 18 ++ .../BoardGame.Host/Properties/AssemblyInfo.cs | 36 +++ api/BoardGame/BoardGame.Host/packages.config | 14 + 12 files changed, 691 insertions(+) create mode 100644 .gitattributes create mode 100644 api/BoardGame/BoardGame.Api.sln create mode 100644 api/BoardGame/BoardGame.Api/BoardGame.Api.csproj create mode 100644 api/BoardGame/BoardGame.Api/Properties/AssemblyInfo.cs create mode 100644 api/BoardGame/BoardGame.Api/Startup.cs create mode 100644 api/BoardGame/BoardGame.Api/packages.config create mode 100644 api/BoardGame/BoardGame.Host/App.config create mode 100644 api/BoardGame/BoardGame.Host/BoardGame.Host.csproj create mode 100644 api/BoardGame/BoardGame.Host/Program.cs create mode 100644 api/BoardGame/BoardGame.Host/Properties/AssemblyInfo.cs create mode 100644 api/BoardGame/BoardGame.Host/packages.config diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore index 570144b..12ae4d0 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,244 @@ app/cordova/www/ # res resources/signing node_modules + +# Created by https://www.gitignore.io/api/windows,visualstudio + +### Windows ### +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + +# Windows shortcuts +*.lnk + + +### VisualStudio ### +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +build/ +bld/ +[Bb]in/ +[Oo]bj/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config + +# Windows Azure Build Output +csx/ +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +[Ss]tyle[Cc]op.* +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions diff --git a/api/BoardGame/BoardGame.Api.sln b/api/BoardGame/BoardGame.Api.sln new file mode 100644 index 0000000..c87d027 --- /dev/null +++ b/api/BoardGame/BoardGame.Api.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BoardGame.Api", "BoardGame.Api\BoardGame.Api.csproj", "{59F84729-1008-495D-9428-35E51EA145D1}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BoardGame.Host", "BoardGame.Host\BoardGame.Host.csproj", "{94504A74-C489-4E88-8647-A0EBE29EC66A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {59F84729-1008-495D-9428-35E51EA145D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {59F84729-1008-495D-9428-35E51EA145D1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {59F84729-1008-495D-9428-35E51EA145D1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {59F84729-1008-495D-9428-35E51EA145D1}.Release|Any CPU.Build.0 = Release|Any CPU + {94504A74-C489-4E88-8647-A0EBE29EC66A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {94504A74-C489-4E88-8647-A0EBE29EC66A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {94504A74-C489-4E88-8647-A0EBE29EC66A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {94504A74-C489-4E88-8647-A0EBE29EC66A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/api/BoardGame/BoardGame.Api/BoardGame.Api.csproj b/api/BoardGame/BoardGame.Api/BoardGame.Api.csproj new file mode 100644 index 0000000..dfbd86a --- /dev/null +++ b/api/BoardGame/BoardGame.Api/BoardGame.Api.csproj @@ -0,0 +1,94 @@ + + + + + Debug + AnyCPU + {59F84729-1008-495D-9428-35E51EA145D1} + Library + Properties + BoardGame.Api + BoardGame.Api + v4.5.2 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\Microsoft.Owin.2.0.2\lib\net45\Microsoft.Owin.dll + True + + + ..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll + True + + + ..\packages\Owin.1.0\lib\net40\Owin.dll + True + + + + + ..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll + True + + + + ..\packages\Microsoft.AspNet.Cors.5.2.3\lib\net45\System.Web.Cors.dll + True + + + ..\packages\Microsoft.AspNet.WebApi.Core.5.2.3\lib\net45\System.Web.Http.dll + True + + + ..\packages\Microsoft.AspNet.WebApi.Cors.5.2.3\lib\net45\System.Web.Http.Cors.dll + True + + + ..\packages\Microsoft.AspNet.WebApi.Owin.5.2.3\lib\net45\System.Web.Http.Owin.dll + True + + + ..\packages\Microsoft.AspNet.WebApi.WebHost.5.2.3\lib\net45\System.Web.Http.WebHost.dll + True + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/api/BoardGame/BoardGame.Api/Properties/AssemblyInfo.cs b/api/BoardGame/BoardGame.Api/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..2f73bd5 --- /dev/null +++ b/api/BoardGame/BoardGame.Api/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("BoardGame.Api")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("BoardGame.Api")] +[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("59f84729-1008-495d-9428-35e51ea145d1")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/api/BoardGame/BoardGame.Api/Startup.cs b/api/BoardGame/BoardGame.Api/Startup.cs new file mode 100644 index 0000000..ed8585e --- /dev/null +++ b/api/BoardGame/BoardGame.Api/Startup.cs @@ -0,0 +1,39 @@ +using System.Net.Http.Formatting; +using System.Web.Http; +using System.Web.Http.Cors; +using Newtonsoft.Json; +using Newtonsoft.Json.Serialization; +using Owin; + +namespace BoardGame.Api +{ + public class Startup + { + public void Configuration(IAppBuilder appBuilder) + { + var httpConfiguration = CreateHttpConfiguration(); + + appBuilder.UseWebApi(httpConfiguration); + } + + private HttpConfiguration CreateHttpConfiguration() + { + var httpConfiguration = new HttpConfiguration(); + httpConfiguration.MapHttpAttributeRoutes(); + httpConfiguration.Routes.MapHttpRoute("default", "api/{controller}/{action}"); + + httpConfiguration.Formatters.Clear(); + httpConfiguration.Formatters.Add(new JsonMediaTypeFormatter() + { + SerializerSettings = new JsonSerializerSettings() + { + ContractResolver = new CamelCasePropertyNamesContractResolver() + } + }); + + httpConfiguration.EnableCors(new EnableCorsAttribute("*", "*", "*")); + + return httpConfiguration; + } + } +} \ No newline at end of file diff --git a/api/BoardGame/BoardGame.Api/packages.config b/api/BoardGame/BoardGame.Api/packages.config new file mode 100644 index 0000000..d5e2b30 --- /dev/null +++ b/api/BoardGame/BoardGame.Api/packages.config @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/api/BoardGame/BoardGame.Host/App.config b/api/BoardGame/BoardGame.Host/App.config new file mode 100644 index 0000000..88fa402 --- /dev/null +++ b/api/BoardGame/BoardGame.Host/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/api/BoardGame/BoardGame.Host/BoardGame.Host.csproj b/api/BoardGame/BoardGame.Host/BoardGame.Host.csproj new file mode 100644 index 0000000..13d0e94 --- /dev/null +++ b/api/BoardGame/BoardGame.Host/BoardGame.Host.csproj @@ -0,0 +1,103 @@ + + + + + Debug + AnyCPU + {94504A74-C489-4E88-8647-A0EBE29EC66A} + Exe + Properties + BoardGame.Host + BoardGame.Host + v4.5.2 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\Microsoft.Owin.2.0.2\lib\net45\Microsoft.Owin.dll + True + + + ..\packages\Microsoft.Owin.Host.HttpListener.2.0.2\lib\net45\Microsoft.Owin.Host.HttpListener.dll + True + + + ..\packages\Microsoft.Owin.Hosting.2.0.2\lib\net45\Microsoft.Owin.Hosting.dll + True + + + ..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll + True + + + ..\packages\Owin.1.0\lib\net40\Owin.dll + True + + + + + ..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll + True + + + ..\packages\Microsoft.AspNet.WebApi.Core.5.2.3\lib\net45\System.Web.Http.dll + True + + + ..\packages\Microsoft.AspNet.WebApi.Owin.5.2.3\lib\net45\System.Web.Http.Owin.dll + True + + + ..\packages\Microsoft.AspNet.WebApi.WebHost.5.2.3\lib\net45\System.Web.Http.WebHost.dll + True + + + + + + + + + + + + + + + + + + + {59F84729-1008-495D-9428-35E51EA145D1} + BoardGame.Api + + + + + \ No newline at end of file diff --git a/api/BoardGame/BoardGame.Host/Program.cs b/api/BoardGame/BoardGame.Host/Program.cs new file mode 100644 index 0000000..95737fc --- /dev/null +++ b/api/BoardGame/BoardGame.Host/Program.cs @@ -0,0 +1,18 @@ +using System; +using BoardGame.Api; +using Microsoft.Owin.Hosting; + +namespace BoardGame.Host +{ + class Program + { + static void Main(string[] args) + { + using (WebApp.Start("http://+:8090")) + { + Console.WriteLine("Server is up and running"); + Console.ReadLine(); + } + } + } +} diff --git a/api/BoardGame/BoardGame.Host/Properties/AssemblyInfo.cs b/api/BoardGame/BoardGame.Host/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..454fd87 --- /dev/null +++ b/api/BoardGame/BoardGame.Host/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("BoardGame.Host")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("BoardGame.Host")] +[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("94504a74-c489-4e88-8647-a0ebe29ec66a")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/api/BoardGame/BoardGame.Host/packages.config b/api/BoardGame/BoardGame.Host/packages.config new file mode 100644 index 0000000..301412a --- /dev/null +++ b/api/BoardGame/BoardGame.Host/packages.config @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file