diff --git a/.idea/.idea.ProjectLighthouse/.idea/discord.xml b/.idea/.idea.ProjectLighthouse/.idea/discord.xml index 30bab2ab..d8e95616 100644 --- a/.idea/.idea.ProjectLighthouse/.idea/discord.xml +++ b/.idea/.idea.ProjectLighthouse/.idea/discord.xml @@ -1,7 +1,7 @@ - \ No newline at end of file diff --git a/ProjectLighthouse/Controllers/LoginController.cs b/ProjectLighthouse/Controllers/LoginController.cs new file mode 100644 index 00000000..587540c2 --- /dev/null +++ b/ProjectLighthouse/Controllers/LoginController.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Primitives; + +namespace ProjectLighthouse.Controllers { + [ApiController] + [Route("LITTLEBIGPLANETPS3_XML/login")] + [Produces("text/xml")] + public class LoginController : ControllerBase { + [HttpGet] + [HttpPost] + public IActionResult Post() { + return this.Ok(new LoginResult { + AuthTicket = "d2c6bbec59162a1e786ed24ad95f2b73", + LbpEnvVer = "rLBP_Cepheus" + }.Serialize()); + } + } +} \ No newline at end of file diff --git a/ProjectLighthouse/Controllers/WeatherForecastController.cs b/ProjectLighthouse/Controllers/WeatherForecastController.cs deleted file mode 100644 index 62410f79..00000000 --- a/ProjectLighthouse/Controllers/WeatherForecastController.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Logging; - -namespace ProjectLighthouse.Controllers { - [ApiController] - [Route("[controller]")] - public class WeatherForecastController : ControllerBase { - private static readonly string[] Summaries = new[] { - "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" - }; - - private readonly ILogger _logger; - - public WeatherForecastController(ILogger logger) { - _logger = logger; - } - - [HttpGet] - public IEnumerable Get() { - var rng = new Random(); - return Enumerable.Range(1, 5).Select(index => new WeatherForecast { - Date = DateTime.Now.AddDays(index), - TemperatureC = rng.Next(-20, 55), - Summary = Summaries[rng.Next(Summaries.Length)] - }) - .ToArray(); - } - } -} \ No newline at end of file diff --git a/ProjectLighthouse/LoginResult.cs b/ProjectLighthouse/LoginResult.cs new file mode 100644 index 00000000..51feb3e2 --- /dev/null +++ b/ProjectLighthouse/LoginResult.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; +using System.Xml.Serialization; +using ProjectLighthouse.Serialization; + +namespace ProjectLighthouse { + public class LoginResult { + public string AuthTicket { get; set; } + public string LbpEnvVer { get; set; } + + public string Serialize() { + return LbpSerializer.GetElements( + new KeyValuePair("authTicket", AuthTicket), + new KeyValuePair("lbpEnvVer", LbpEnvVer) + ); + } + } +} \ No newline at end of file diff --git a/ProjectLighthouse/Properties/launchSettings.json b/ProjectLighthouse/Properties/launchSettings.json index 9db7edf5..66ac9acb 100644 --- a/ProjectLighthouse/Properties/launchSettings.json +++ b/ProjectLighthouse/Properties/launchSettings.json @@ -11,8 +11,6 @@ "profiles": { "IIS Express": { "commandName": "IISExpress", - "launchBrowser": true, - "launchUrl": "swagger", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } @@ -20,8 +18,6 @@ "ProjectLighthouse": { "commandName": "Project", "dotnetRunMessages": "true", - "launchBrowser": true, - "launchUrl": "swagger", "applicationUrl": "https://localhost:5001;http://localhost:5000", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" diff --git a/ProjectLighthouse/Serialization/LbpSerializer.cs b/ProjectLighthouse/Serialization/LbpSerializer.cs new file mode 100644 index 00000000..63cef961 --- /dev/null +++ b/ProjectLighthouse/Serialization/LbpSerializer.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; + +namespace ProjectLighthouse.Serialization { + public static class LbpSerializer { + public static string GetBlankElement(string key) => $"<{key}>"; + + public static string GetStringElement(KeyValuePair pair) => $"<{pair.Key}>{pair.Value}"; + + public static string GetStringElement(string key, object value) => $"<{key}>{value}"; + + public static string GetElements(params KeyValuePair[] pairs) => + pairs.Aggregate(string.Empty, (current, pair) => current + GetStringElement(pair)); + } +} \ No newline at end of file diff --git a/ProjectLighthouse/Serialization/XmlOutputFormatter.cs b/ProjectLighthouse/Serialization/XmlOutputFormatter.cs new file mode 100644 index 00000000..0ed5eb53 --- /dev/null +++ b/ProjectLighthouse/Serialization/XmlOutputFormatter.cs @@ -0,0 +1,10 @@ +using Microsoft.AspNetCore.Mvc.Formatters; + +namespace ProjectLighthouse.Serialization { + public class XmlOutputFormatter : StringOutputFormatter { + public XmlOutputFormatter() { + SupportedMediaTypes.Add("text/xml"); + SupportedMediaTypes.Add("application/xml"); + } + } +} \ No newline at end of file diff --git a/ProjectLighthouse/Startup.cs b/ProjectLighthouse/Startup.cs index 1924fdb0..b54478ad 100644 --- a/ProjectLighthouse/Startup.cs +++ b/ProjectLighthouse/Startup.cs @@ -11,6 +11,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Microsoft.OpenApi.Models; +using ProjectLighthouse.Serialization; namespace ProjectLighthouse { public class Startup { @@ -24,17 +25,14 @@ namespace ProjectLighthouse { public void ConfigureServices(IServiceCollection services) { services.AddControllers(); - services.AddSwaggerGen(c => { - c.SwaggerDoc("v1", new OpenApiInfo { Title = "ProjectLighthouse", Version = "v1" }); - }); + services.AddMvc(options => + options.OutputFormatters.Add(new XmlOutputFormatter())); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if(env.IsDevelopment()) { app.UseDeveloperExceptionPage(); - app.UseSwagger(); - app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "ProjectLighthouse v1")); } app.UseHttpsRedirection(); diff --git a/ProjectLighthouse/WeatherForecast.cs b/ProjectLighthouse/WeatherForecast.cs deleted file mode 100644 index f3d38082..00000000 --- a/ProjectLighthouse/WeatherForecast.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; - -namespace ProjectLighthouse { - public class WeatherForecast { - public DateTime Date { get; set; } - - public int TemperatureC { get; set; } - - public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); - - public string Summary { get; set; } - } -} \ No newline at end of file