Skip to content

Commit

Permalink
Merge pull request #27 from Cysharp/next-v
Browse files Browse the repository at this point in the history
Improve array handling, remove Utf8Json dependency
  • Loading branch information
neuecc authored Jan 1, 2020
2 parents 55c982f + 5e1901d commit 4dfb120
Show file tree
Hide file tree
Showing 10 changed files with 272 additions and 266 deletions.
23 changes: 23 additions & 0 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,29 @@ You can call like here.
> SampleApp.exe -array [10,20,30] -person {"Age":10,"Name":"foo"}
```

For the array handling, it can be a treat without correct JSON.
e.g. one-length argument can handle without `[]`.

```csharp
Foo(int[] array)
> SampleApp.exe -array 9999
```

multiple-argument can handle by split with ` `.

```csharp
Foo(int[] array)
> SampleApp.exe -array "11 22 33"
```

string argument can handle without `"`.

```csharp
Foo(string[] array)
> SampleApp.exe -array "hello"
> SampleApp.exe -array "foo bar baz"
```

Exit Code
---
If the batch method returns `int` or `Task<int>` value, BatchEngine will set the return value to the exit code.
Expand Down
7 changes: 4 additions & 3 deletions sandbox/SingleContainedApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Text;
Expand Down Expand Up @@ -114,9 +115,9 @@ public void Help()

public class ComplexArgTest : BatchBase
{
public void Foo(int[] array, Person person)
public void Foo(string[] array, Person person)
{
Console.WriteLine(string.Join(", ", array));
Console.WriteLine(array.Length + ":" + string.Join(", ", array));
Console.WriteLine(person.Age + ":" + person.Name);
}
}
Expand All @@ -131,7 +132,7 @@ class Program
{
static async Task Main(string[] args)
{
args = @"-array [10,20,30] -person {""Age"":10,""Name"":""foo""}".Split(' ');
args = new[] { "-array", "foo bar baz", "-person", @"{""Age"":10,""Name"":""foo""}" };

await BatchHost.CreateDefaultBuilder()
.ConfigureServices((hostContext, services) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -66,7 +67,7 @@ public static IApplicationBuilder UseBatchEngineSwaggerMiddleware(this IApplicat

public class DefaultStartup
{
public void Configure(IApplicationBuilder app, IApplicationLifetime lifetime)
public void Configure(IApplicationBuilder app, IHostApplicationLifetime lifetime)
{
var interceptor = app.ApplicationServices.GetService<IBatchInterceptor>();
var provider = app.ApplicationServices.GetService<IServiceProvider>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<LangVersion>8.0</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<LangVersion>8.0</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<EmbeddedResource Include="Swagger\SwaggerUI\*" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Swagger\SwaggerUI\*" />
</ItemGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Text.Json" Version="4.7.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\MicroBatchFramework\MicroBatchFramework.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MicroBatchFramework\MicroBatchFramework.csproj" />
</ItemGroup>

</Project>
Loading

0 comments on commit 4dfb120

Please sign in to comment.