Skip to content

Commit 4dfb120

Browse files
authored
Merge pull request #27 from Cysharp/next-v
Improve array handling, remove Utf8Json dependency
2 parents 55c982f + 5e1901d commit 4dfb120

File tree

10 files changed

+272
-266
lines changed

10 files changed

+272
-266
lines changed

ReadMe.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,29 @@ You can call like here.
216216
> SampleApp.exe -array [10,20,30] -person {"Age":10,"Name":"foo"}
217217
```
218218

219+
For the array handling, it can be a treat without correct JSON.
220+
e.g. one-length argument can handle without `[]`.
221+
222+
```csharp
223+
Foo(int[] array)
224+
> SampleApp.exe -array 9999
225+
```
226+
227+
multiple-argument can handle by split with ` `.
228+
229+
```csharp
230+
Foo(int[] array)
231+
> SampleApp.exe -array "11 22 33"
232+
```
233+
234+
string argument can handle without `"`.
235+
236+
```csharp
237+
Foo(string[] array)
238+
> SampleApp.exe -array "hello"
239+
> SampleApp.exe -array "foo bar baz"
240+
```
241+
219242
Exit Code
220243
---
221244
If the batch method returns `int` or `Task<int>` value, BatchEngine will set the return value to the exit code.

sandbox/SingleContainedApp/Program.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Microsoft.Extensions.Logging;
77
using Microsoft.Extensions.Options;
88
using System;
9+
using System.Collections.Generic;
910
using System.IO;
1011
using System.Reflection;
1112
using System.Text;
@@ -114,9 +115,9 @@ public void Help()
114115

115116
public class ComplexArgTest : BatchBase
116117
{
117-
public void Foo(int[] array, Person person)
118+
public void Foo(string[] array, Person person)
118119
{
119-
Console.WriteLine(string.Join(", ", array));
120+
Console.WriteLine(array.Length + ":" + string.Join(", ", array));
120121
Console.WriteLine(person.Age + ":" + person.Name);
121122
}
122123
}
@@ -131,7 +132,7 @@ class Program
131132
{
132133
static async Task Main(string[] args)
133134
{
134-
args = @"-array [10,20,30] -person {""Age"":10,""Name"":""foo""}".Split(' ');
135+
args = new[] { "-array", "foo bar baz", "-person", @"{""Age"":10,""Name"":""foo""}" };
135136

136137
await BatchHost.CreateDefaultBuilder()
137138
.ConfigureServices((hostContext, services) =>

src/MicroBatchFramework.WebHosting/BatchEngineHostingExtensions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Microsoft.AspNetCore.Builder;
44
using Microsoft.AspNetCore.Hosting;
55
using Microsoft.Extensions.DependencyInjection;
6+
using Microsoft.Extensions.Hosting;
67
using Microsoft.Extensions.Logging;
78
using System;
89
using System.Collections.Generic;
@@ -66,7 +67,7 @@ public static IApplicationBuilder UseBatchEngineSwaggerMiddleware(this IApplicat
6667

6768
public class DefaultStartup
6869
{
69-
public void Configure(IApplicationBuilder app, IApplicationLifetime lifetime)
70+
public void Configure(IApplicationBuilder app, IHostApplicationLifetime lifetime)
7071
{
7172
var interceptor = app.ApplicationServices.GetService<IBatchInterceptor>();
7273
var provider = app.ApplicationServices.GetService<IServiceProvider>();
Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.0</TargetFramework>
5-
<LangVersion>8.0</LangVersion>
6-
<Nullable>enable</Nullable>
7-
</PropertyGroup>
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp3.0</TargetFramework>
5+
<LangVersion>8.0</LangVersion>
6+
<Nullable>enable</Nullable>
7+
</PropertyGroup>
88

9-
<ItemGroup>
10-
<EmbeddedResource Include="Swagger\SwaggerUI\*" />
11-
</ItemGroup>
9+
<ItemGroup>
10+
<EmbeddedResource Include="Swagger\SwaggerUI\*" />
11+
</ItemGroup>
1212

13-
<ItemGroup>
14-
<FrameworkReference Include="Microsoft.AspNetCore.App" />
15-
</ItemGroup>
13+
<ItemGroup>
14+
<FrameworkReference Include="Microsoft.AspNetCore.App" />
15+
</ItemGroup>
1616

17-
<ItemGroup>
18-
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
19-
</ItemGroup>
17+
<ItemGroup>
18+
<PackageReference Include="System.Text.Json" Version="4.7.0" />
19+
</ItemGroup>
2020

21-
<ItemGroup>
22-
<ProjectReference Include="..\MicroBatchFramework\MicroBatchFramework.csproj" />
23-
</ItemGroup>
21+
<ItemGroup>
22+
<ProjectReference Include="..\MicroBatchFramework\MicroBatchFramework.csproj" />
23+
</ItemGroup>
2424

2525
</Project>

0 commit comments

Comments
 (0)