Skip to content

Commit b27ecac

Browse files
committed
sample project configured
1 parent 8e3e131 commit b27ecac

3 files changed

Lines changed: 50 additions & 12 deletions

File tree

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,44 @@
1+
using System.Collections.Generic ;
12
using Microsoft.AspNetCore.Mvc;
23

34
namespace WebApplication.Controllers
45
{
56
public class HomeController : Controller
67
{
7-
public IActionResult Index()
8+
public List<dynamic> Index()
89
{
9-
return Json("");
10+
var response = new List<dynamic>()
11+
{
12+
new
13+
{
14+
Foo = 1,
15+
Bar = new
16+
{
17+
Baz = 2,
18+
Qux = 3
19+
}
20+
},
21+
new
22+
{
23+
Foo = 2,
24+
Bar = new
25+
{
26+
Baz = 3,
27+
Qux = 4
28+
}
29+
},
30+
new
31+
{
32+
Foo = 3,
33+
Bar = new
34+
{
35+
Baz = 5,
36+
Qux = 6
37+
}
38+
}
39+
};
40+
41+
return response;
1042
}
1143
}
1244
}

samples/PartialResponse.AspNetCore.Mvc.Demo/Startup.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Microsoft.Extensions.Configuration;
44
using Microsoft.Extensions.DependencyInjection;
55
using Microsoft.Extensions.Logging;
6+
using PartialResponse.Extensions.DependencyInjection;
67

78
namespace WebApplication
89
{
@@ -24,7 +25,9 @@ public Startup(IHostingEnvironment env)
2425

2526
public void ConfigureServices(IServiceCollection services)
2627
{
27-
services.AddMvc();
28+
services
29+
.AddMvc(options => options.OutputFormatters.Clear())
30+
.AddPartialJsonFormatters();
2831
}
2932

3033
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)

samples/PartialResponse.AspNetCore.Mvc.Demo/project.json

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
{
22
"dependencies": {
3+
"PartialResponse.AspNetCore.Mvc.Formatters.Json": {
4+
"target": "project"
5+
},
36
"Microsoft.NETCore.App": {
47
"version": "1.1.0",
58
"type": "platform"
69
},
7-
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
8-
"Microsoft.AspNetCore.Mvc": "1.0.1",
9-
"Microsoft.AspNetCore.Routing": "1.0.1",
10-
"Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
11-
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
12-
"Microsoft.Extensions.Configuration.Json": "1.0.0",
13-
"Microsoft.Extensions.Logging": "1.0.0",
14-
"Microsoft.Extensions.Logging.Console": "1.0.0",
15-
"Microsoft.Extensions.Logging.Debug": "1.0.0"
10+
"Microsoft.AspNetCore.Diagnostics": "1.1.0",
11+
"Microsoft.AspNetCore.Mvc": "1.1.0",
12+
"Microsoft.AspNetCore.Routing": "1.1.0",
13+
"Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
14+
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0",
15+
"Microsoft.Extensions.Configuration.Json": "1.1.0",
16+
"Microsoft.Extensions.Logging": "1.1.0",
17+
"Microsoft.Extensions.Logging.Console": "1.1.0",
18+
"Microsoft.Extensions.Logging.Debug": "1.1.0"
1619
},
1720

1821
"frameworks": {

0 commit comments

Comments
 (0)