Skip to content
This repository has been archived by the owner on Jul 3, 2020. It is now read-only.

Commit

Permalink
front matters
Browse files Browse the repository at this point in the history
  • Loading branch information
OpportunityLiu committed Nov 19, 2019
1 parent 3f5eb1a commit c320edd
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 61 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

/EhTT-DB/

# User-specific files
*.suo
*.user
Expand Down
2 changes: 1 addition & 1 deletion EhDbReleaseBuilder/EhDbReleaseBuilder.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>netcoreapp2.2</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion EhDbReleaseBuilder/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"profiles": {
"EhDbReleaseBuilder": {
"commandName": "Project",
"commandLineArgs": "C:\\Users\\lzy\\Documents\\Source\\EhTagTranslation\\EhTagConnector\\EhTT-DB\\ C:\\Users\\lzy\\Documents\\Source\\EhTagTranslation\\EhTagConnector\\EhTT-DB\\publish"
"commandLineArgs": "C:\\Users\\lzy\\Documents\\Source\\EhTagTranslation\\EhTagConnector\\EhTagApi\\Db\\ C:\\Users\\lzy\\Documents\\Source\\EhTagTranslation\\EhTagConnector\\EhTagApi\\Db\\publish"
}
}
}
7 changes: 5 additions & 2 deletions EhTagApi/EhTagApi.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>netcoreapp2.2</TargetFramework>
<LangVersion>latest</LangVersion>
<ApplicationIcon />
<OutputType>Exe</OutputType>
<StartupObject />
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.0.0" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Octokit" Version="0.36.0" />
</ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions EhTagApi/Formatters/AstOutputFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

namespace EhTagApi.Formatters
{
public class AstOutputFormatter : NewtonsoftJsonOutputFormatter
public class AstOutputFormatter : JsonOutputFormatter
{
public AstOutputFormatter(Microsoft.AspNetCore.Mvc.MvcOptions mvcOptions) : base(Consts.SerializerSettings, ArrayPool<char>.Shared, mvcOptions)
public AstOutputFormatter() : base(Consts.SerializerSettings, ArrayPool<char>.Shared)
{
SerializerSettings.Converters.Add(new MdConverter(MdConverter.ConvertType.Ast));
SupportedMediaTypes.Clear();
Expand Down
16 changes: 0 additions & 16 deletions EhTagApi/Formatters/FullOutputFormatter.cs

This file was deleted.

4 changes: 2 additions & 2 deletions EhTagApi/Formatters/HtmlOutputFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace EhTagApi.Formatters
{
public class HtmlOutputFormatter : NewtonsoftJsonOutputFormatter
public class HtmlOutputFormatter : JsonOutputFormatter
{
public HtmlOutputFormatter(Microsoft.AspNetCore.Mvc.MvcOptions mvcOptions) : base(Consts.SerializerSettings, ArrayPool<char>.Shared, mvcOptions)
public HtmlOutputFormatter() : base(Consts.SerializerSettings, ArrayPool<char>.Shared)
{
SerializerSettings.Converters.Add(new MdConverter(MdConverter.ConvertType.Html));
SupportedMediaTypes.Clear();
Expand Down
6 changes: 4 additions & 2 deletions EhTagApi/Formatters/RawOutputFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@

namespace EhTagApi.Formatters
{
public class RawOutputFormatter : NewtonsoftJsonOutputFormatter
public class RawOutputFormatter : JsonOutputFormatter
{
public RawOutputFormatter(Microsoft.AspNetCore.Mvc.MvcOptions mvcOptions) : base(Consts.SerializerSettings, ArrayPool<char>.Shared, mvcOptions)
public RawOutputFormatter() : base(Consts.SerializerSettings, ArrayPool<char>.Shared)
{
SerializerSettings.Converters.Add(new MdConverter(MdConverter.ConvertType.Raw));
SupportedMediaTypes.Clear();
SupportedMediaTypes.Add("application/raw+json");
}

public override bool CanWriteResult(OutputFormatterCanWriteContext context) => base.CanWriteResult(context);
}
}
4 changes: 2 additions & 2 deletions EhTagApi/Formatters/TextOutputFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace EhTagApi.Formatters
{
public class TextOutputFormatter : NewtonsoftJsonOutputFormatter
public class TextOutputFormatter : JsonOutputFormatter
{
public TextOutputFormatter(Microsoft.AspNetCore.Mvc.MvcOptions mvcOptions) : base(Consts.SerializerSettings, ArrayPool<char>.Shared, mvcOptions)
public TextOutputFormatter() : base(Consts.SerializerSettings, ArrayPool<char>.Shared)
{
SerializerSettings.Converters.Add(new MdConverter(MdConverter.ConvertType.Text));
SupportedMediaTypes.Clear();
Expand Down
47 changes: 23 additions & 24 deletions EhTagApi/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System;
Expand Down Expand Up @@ -54,24 +53,18 @@ public void ConfigureServices(IServiceCollection services)
.Build());
});

services.AddControllers(options =>
services.AddMvc(options =>
{
options.OutputFormatters.Add(new Formatters.FullOutputFormatter(options));
options.OutputFormatters.Add(new Formatters.RawOutputFormatter(options));
options.OutputFormatters.Add(new Formatters.TextOutputFormatter(options));
options.OutputFormatters.Add(new Formatters.HtmlOutputFormatter(options));
options.OutputFormatters.Add(new Formatters.AstOutputFormatter(options));
var defOutput = options.OutputFormatters.OfType<Microsoft.AspNetCore.Mvc.Formatters.JsonOutputFormatter>().First();
defOutput.SupportedMediaTypes.Clear();
defOutput.SupportedMediaTypes.Add("application/json");
defOutput.SupportedMediaTypes.Add("application/problem+json");
options.OutputFormatters.Add(new Formatters.RawOutputFormatter());
options.OutputFormatters.Add(new Formatters.TextOutputFormatter());
options.OutputFormatters.Add(new Formatters.HtmlOutputFormatter());
options.OutputFormatters.Add(new Formatters.AstOutputFormatter());
options.InputFormatters.Add(new Formatters.TextFormatter());
}).AddNewtonsoftJson(options =>
{
var serializer = Newtonsoft.Json.JsonSerializer.Create(new Newtonsoft.Json.JsonSerializerSettings
{
TypeNameHandling = Newtonsoft.Json.TypeNameHandling.All,
});
var tw = new StringWriter();
serializer.Serialize(tw, Consts.SerializerSettings);
serializer.Populate(new StringReader(tw.ToString()), options.SerializerSettings);
})
.AddFormatterMappings(options =>
{
Expand All @@ -81,11 +74,21 @@ public void ConfigureServices(IServiceCollection services)
options.SetMediaTypeMappingForFormat("ast.json", "application/ast+json");
})
.AddXmlSerializerFormatters()
.SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
.SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
.AddJsonOptions(options =>
{
var serializer = Newtonsoft.Json.JsonSerializer.Create(new Newtonsoft.Json.JsonSerializerSettings
{
TypeNameHandling = Newtonsoft.Json.TypeNameHandling.All,
});
var tw = new StringWriter();
serializer.Serialize(tw, Consts.SerializerSettings);
serializer.Populate(new StringReader(tw.ToString()), options.SerializerSettings);
});
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
Expand All @@ -94,14 +97,10 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
else
{
}
app.UseHttpsRedirection();

app.UseCors();
app.UseRouting();
app.UseResponseCompression();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
app.UseMvc();
}
}
}
6 changes: 2 additions & 4 deletions EhTagApi/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
"Default": "Warning"
}
},
"AllowedHosts": "*"
}
}
2 changes: 1 addition & 1 deletion EhTagClient/Consts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace EhTagClient
{
public static class Consts
{
internal const string REPO_PATH = "./DB";
internal const string REPO_PATH = "./Db";
internal const string OWNER = "EhTagTranslation";
internal const string REPO = "Database";

Expand Down
2 changes: 1 addition & 1 deletion EhTagClient/EhTagClient.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>netcoreapp2.2</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion EhTagConnector.sln
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
README.md = README.md
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EhDbReleaseBuilder", "EhDbReleaseBuilder\EhDbReleaseBuilder.csproj", "{44D148EC-770A-4A99-A882-5464C0C9CE1A}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EhDbReleaseBuilder", "EhDbReleaseBuilder\EhDbReleaseBuilder.csproj", "{44D148EC-770A-4A99-A882-5464C0C9CE1A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down

0 comments on commit c320edd

Please sign in to comment.