summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-09-21 23:35:18 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-09-21 23:35:18 -0400
commit9791de306c22c744732219dadfd97b7dd556a5b2 (patch)
treef320674827f3535cf238106070fefd5a762a2a0f
parent57d9d28554de79734401a68ee1151fc4e9e0ca83 (diff)
downloadSMAPI-9791de306c22c744732219dadfd97b7dd556a5b2.tar.gz
SMAPI-9791de306c22c744732219dadfd97b7dd556a5b2.tar.bz2
SMAPI-9791de306c22c744732219dadfd97b7dd556a5b2.zip
minor cleanup, formatting, documentation (#336)
-rw-r--r--Dewdrop.sln22
-rw-r--r--Dewdrop/Controllers/CheckController.cs8
-rw-r--r--Dewdrop/Models/IModModel.cs18
-rw-r--r--Dewdrop/Models/ModGenericModel.cs37
-rw-r--r--Dewdrop/Models/NexusResponseModel.cs47
-rw-r--r--Dewdrop/Program.cs22
-rw-r--r--Dewdrop/Startup.cs39
-rw-r--r--src/StardewModdingAPI.sln17
8 files changed, 98 insertions, 112 deletions
diff --git a/Dewdrop.sln b/Dewdrop.sln
deleted file mode 100644
index 761e6ccc..00000000
--- a/Dewdrop.sln
+++ /dev/null
@@ -1,22 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.26430.16
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dewdrop", "Dewdrop\Dewdrop.csproj", "{0DEC7A86-4D43-43B0-A5F8-7686DDB6EC97}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {0DEC7A86-4D43-43B0-A5F8-7686DDB6EC97}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {0DEC7A86-4D43-43B0-A5F8-7686DDB6EC97}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {0DEC7A86-4D43-43B0-A5F8-7686DDB6EC97}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {0DEC7A86-4D43-43B0-A5F8-7686DDB6EC97}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/Dewdrop/Controllers/CheckController.cs b/Dewdrop/Controllers/CheckController.cs
index f3cdd364..def2edbc 100644
--- a/Dewdrop/Controllers/CheckController.cs
+++ b/Dewdrop/Controllers/CheckController.cs
@@ -8,10 +8,16 @@ using Dewdrop.Models;
namespace Dewdrop.Controllers
{
+ /// <summary>Provides an API to perform mod update checks.</summary>
[Produces("application/json")]
[Route("api/check")]
public class CheckController : Controller
{
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Fetch version metadata for the given mods.</summary>
+ /// <param name="mods">The mods for which to fetch update metadata.</param>
[HttpPost]
public async Task<string> Post([FromBody] NexusResponseModel[] mods)
{
@@ -25,7 +31,7 @@ namespace Dewdrop.Controllers
try
{
// create request with HttpRequestMessage
- var request = new HttpRequestMessage(HttpMethod.Get, new Uri($"http://www.nexusmods.com/stardewvalley/mods/{mod.Id}"));
+ var request = new HttpRequestMessage(HttpMethod.Get, new Uri($"http://www.nexusmods.com/stardewvalley/mods/{mod.ID}"));
// add the Nexus Client useragent to get JSON response from the site
request.Headers.UserAgent.ParseAdd("Nexus Client v0.63.15");
diff --git a/Dewdrop/Models/IModModel.cs b/Dewdrop/Models/IModModel.cs
index aa6583d4..f1b09f8a 100644
--- a/Dewdrop/Models/IModModel.cs
+++ b/Dewdrop/Models/IModModel.cs
@@ -1,16 +1,12 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-
-namespace Dewdrop.Models
+namespace Dewdrop.Models
{
- interface IModModel
+ /// <summary>A mod metadata response which provides a method to extract generic info.</summary>
+ internal interface IModModel
{
- /// <summary>
- /// Basic information in the form of <see cref="ModGenericModel"/>
- /// </summary>
- /// <returns><see cref="ModGenericModel"/></returns>
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Get basic mod metadata.</summary>
ModGenericModel ModInfo();
}
}
diff --git a/Dewdrop/Models/ModGenericModel.cs b/Dewdrop/Models/ModGenericModel.cs
index 829c396a..0da04295 100644
--- a/Dewdrop/Models/ModGenericModel.cs
+++ b/Dewdrop/Models/ModGenericModel.cs
@@ -1,40 +1,27 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-
-namespace Dewdrop.Models
+namespace Dewdrop.Models
{
+ /// <summary>Generic metadata about a mod.</summary>
public class ModGenericModel
{
- /// <summary>
- /// An identifier for the mod.
- /// </summary>
- public int Id { get; set; }
+ /*********
+ ** Accessors
+ *********/
+ /// <summary>The unique mod ID.</summary>
+ public int ID { get; set; }
- /// <summary>
- /// The mod's name.
- /// </summary>
+ /// <summary>The mod name.</summary>
public string Name { get; set; }
- /// <summary>
- /// The vendor identifier for the mod.
- /// </summary>
+ /// <summary>The mod's vendor ID.</summary>
public string Vendor { get; set; }
- /// <summary>
- /// The mod's version number.
- /// </summary>
+ /// <summary>The mod's semantic version number.</summary>
public string Version { get; set; }
- /// <summary>
- /// The mod's URL
- /// </summary>
+ /// <summary>The mod's web URL.</summary>
public string Url { get; set; }
- /// <summary>
- /// Is the mod a valid mod.
- /// </summary>
+ /// <summary>Whether the mod is valid.</summary>
public bool Valid { get; set; } = true;
}
}
diff --git a/Dewdrop/Models/NexusResponseModel.cs b/Dewdrop/Models/NexusResponseModel.cs
index e954a8bc..fa663910 100644
--- a/Dewdrop/Models/NexusResponseModel.cs
+++ b/Dewdrop/Models/NexusResponseModel.cs
@@ -1,46 +1,39 @@
-using System;
-using Newtonsoft.Json;
+using Newtonsoft.Json;
namespace Dewdrop.Models
{
+ /// <summary>A mod metadata response from Nexus Mods.</summary>
public class NexusResponseModel : IModModel
{
- /// <summary>
- /// The name of the mod.
- /// </summary>
- [JsonProperty("name")]
+ /*********
+ ** Accessors
+ *********/
+ /// <summary>The unique mod ID.</summary>
+ public int ID { get; set; }
+
+ /// <summary>The mod name.</summary>
public string Name { get; set; }
- /// <summary>
- /// The version of the mod.
- /// </summary>
- [JsonProperty("version")]
+ /// <summary>The mod's semantic version number.</summary>
public string Version { get; set; }
- /// <summary>
- /// The NexusMod ID for the mod.
- /// </summary>
- [JsonProperty("id")]
- public int Id { get; set; }
-
- /// <summary>
- /// The URL of the mod.
- /// </summary>
+ /// <summary>The mod's web URL.</summary>
[JsonProperty("mod_page_uri")]
public string Url { get; set; }
- /// <summary>
- /// Return mod information about a Nexus mod
- /// </summary>
- /// <returns><see cref="ModGenericModel"/></returns>
+
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Get basic mod metadata.</summary>
public ModGenericModel ModInfo()
{
return new ModGenericModel
{
- Id = Id,
- Version = Version,
- Name = Name,
- Url = Url,
+ ID = this.ID,
+ Version = this.Version,
+ Name = this.Name,
+ Url = this.Url,
Vendor = "Nexus"
};
}
diff --git a/Dewdrop/Program.cs b/Dewdrop/Program.cs
index c6a5a642..0e831a23 100644
--- a/Dewdrop/Program.cs
+++ b/Dewdrop/Program.cs
@@ -1,27 +1,27 @@
-using System;
-using System.IO;
-using System.Net.Http;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Builder;
+using System.IO;
using Microsoft.AspNetCore.Hosting;
-using Newtonsoft.Json;
-using System.Collections.Generic;
namespace Dewdrop
{
+ /// <summary>The main app entry point.</summary>
public class Program
{
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>The main app entry point.</summary>
+ /// <param name="args">The command-line arguments.</param>
public static void Main(string[] args)
{
- var host = new WebHostBuilder()
+ // configure web server
+ new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.UseApplicationInsights()
- .Build();
-
- host.Run();
+ .Build()
+ .Run();
}
}
}
diff --git a/Dewdrop/Startup.cs b/Dewdrop/Startup.cs
index 00c18bab..d1618037 100644
--- a/Dewdrop/Startup.cs
+++ b/Dewdrop/Startup.cs
@@ -1,8 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
@@ -10,33 +6,46 @@ using Microsoft.Extensions.Logging;
namespace Dewdrop
{
+ /// <summary>The web app startup configuration.</summary>
public class Startup
{
+ /*********
+ ** Accessors
+ *********/
+ /// <summary>The web app configuration.</summary>
+ public IConfigurationRoot Configuration { get; }
+
+
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Construct an instance.</summary>
+ /// <param name="env">The hosting environment.</param>
public Startup(IHostingEnvironment env)
{
- var builder = new ConfigurationBuilder()
+ this.Configuration = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
- .AddEnvironmentVariables();
- Configuration = builder.Build();
+ .AddEnvironmentVariables()
+ .Build();
}
- public IConfigurationRoot Configuration { get; }
-
- // This method gets called by the runtime. Use this method to add services to the container.
+ /// <summary>The method called by the runtime to add services to the container.</summary>
+ /// <param name="services">The service injection container.</param>
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.
+ /// <summary>The method called by the runtime to configure the HTTP request pipeline.</summary>
+ /// <param name="app">The application builder.</param>
+ /// <param name="env">The hosting environment.</param>
+ /// <param name="loggerFactory">The logger factory.</param>
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
- loggerFactory.AddConsole(Configuration.GetSection("Logging"));
+ loggerFactory.AddConsole(this.Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
-
app.UseMvc();
}
}
diff --git a/src/StardewModdingAPI.sln b/src/StardewModdingAPI.sln
index a2e0ec44..3cf129c0 100644
--- a/src/StardewModdingAPI.sln
+++ b/src/StardewModdingAPI.sln
@@ -29,6 +29,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StardewModdingAPI.Installer
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StardewModdingAPI.Tests", "StardewModdingAPI.Tests\StardewModdingAPI.Tests.csproj", "{36CCB19E-92EB-48C7-9615-98EEFD45109B}"
EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dewdrop", "..\Dewdrop\Dewdrop.csproj", "{A308F679-51A3-4006-92D5-BAEC7EBD01A1}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -79,8 +81,23 @@ Global
{36CCB19E-92EB-48C7-9615-98EEFD45109B}.Release|Mixed Platforms.Build.0 = Release|x86
{36CCB19E-92EB-48C7-9615-98EEFD45109B}.Release|x86.ActiveCfg = Release|x86
{36CCB19E-92EB-48C7-9615-98EEFD45109B}.Release|x86.Build.0 = Release|x86
+ {A308F679-51A3-4006-92D5-BAEC7EBD01A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A308F679-51A3-4006-92D5-BAEC7EBD01A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A308F679-51A3-4006-92D5-BAEC7EBD01A1}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {A308F679-51A3-4006-92D5-BAEC7EBD01A1}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {A308F679-51A3-4006-92D5-BAEC7EBD01A1}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {A308F679-51A3-4006-92D5-BAEC7EBD01A1}.Debug|x86.Build.0 = Debug|Any CPU
+ {A308F679-51A3-4006-92D5-BAEC7EBD01A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A308F679-51A3-4006-92D5-BAEC7EBD01A1}.Release|Any CPU.Build.0 = Release|Any CPU
+ {A308F679-51A3-4006-92D5-BAEC7EBD01A1}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {A308F679-51A3-4006-92D5-BAEC7EBD01A1}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {A308F679-51A3-4006-92D5-BAEC7EBD01A1}.Release|x86.ActiveCfg = Release|Any CPU
+ {A308F679-51A3-4006-92D5-BAEC7EBD01A1}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {70143042-A862-47A8-A677-7C819DDC90DC}
+ EndGlobalSection
EndGlobal