Add example_project
This commit is contained in:
parent
ab80288568
commit
a091bc67dd
4 changed files with 51 additions and 0 deletions
2
test/dotnet/example_project/.gitignore
vendored
Normal file
2
test/dotnet/example_project/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
bin
|
||||
obj
|
8
test/dotnet/example_project/Movie.cs
Normal file
8
test/dotnet/example_project/Movie.cs
Normal file
|
@ -0,0 +1,8 @@
|
|||
// See https://aka.ms/new-console-template for more information
|
||||
|
||||
internal class Movie
|
||||
{
|
||||
public string Name { get; set; } = "Default Name";
|
||||
public DateTime ReleaseDate { get; set; }
|
||||
public List<string> Genres { get; set; } = new List<string>();
|
||||
}
|
27
test/dotnet/example_project/Program.cs
Normal file
27
test/dotnet/example_project/Program.cs
Normal file
|
@ -0,0 +1,27 @@
|
|||
// See https://aka.ms/new-console-template for more information
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
Console.WriteLine("Hello, World!");
|
||||
|
||||
string json = @"{
|
||||
'Name': 'Inception',
|
||||
'ReleaseDate': '2010-07-08T00:00:00',
|
||||
'Genres': [
|
||||
'Action',
|
||||
'Thriller'
|
||||
]
|
||||
}";
|
||||
|
||||
Movie? m = JsonConvert.DeserializeObject<Movie>(json);
|
||||
|
||||
if (m == default)
|
||||
{
|
||||
Console.WriteLine("Decoding failed!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"Name: {m.Name}");
|
||||
Console.WriteLine($"Release Date: {m.ReleaseDate}");
|
||||
Console.WriteLine($"Genres: {string.Join(", ", m.Genres)}");
|
||||
}
|
14
test/dotnet/example_project/example_project.csproj
Normal file
14
test/dotnet/example_project/example_project.csproj
Normal file
|
@ -0,0 +1,14 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
Loading…
Reference in a new issue