From e3ffc42afeb7ade972a702735ae95afc7f12f995 Mon Sep 17 00:00:00 2001 From: Mili Date: Wed, 31 May 2023 22:19:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=A1=B9=E7=9B=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FunGame.Testing.csproj | 16 ++++++++++++++++ FunGame.Testing.sln | 25 +++++++++++++++++++++++++ Main.cs | 6 ++++++ Solutions/DataTable.cs | 27 +++++++++++++++++++++++++++ 4 files changed, 74 insertions(+) create mode 100644 FunGame.Testing.csproj create mode 100644 FunGame.Testing.sln create mode 100644 Main.cs create mode 100644 Solutions/DataTable.cs diff --git a/FunGame.Testing.csproj b/FunGame.Testing.csproj new file mode 100644 index 0000000..90658b8 --- /dev/null +++ b/FunGame.Testing.csproj @@ -0,0 +1,16 @@ + + + + Exe + net7.0 + enable + enable + + + + + ..\FunGame.Core\bin\Debug\net7.0\FunGame.Core.dll + + + + diff --git a/FunGame.Testing.sln b/FunGame.Testing.sln new file mode 100644 index 0000000..b737fd3 --- /dev/null +++ b/FunGame.Testing.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33516.290 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FunGame.Testing", "FunGame.Testing.csproj", "{6F6B4A21-8F39-4B0D-84E8-98AE3E93F06F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6F6B4A21-8F39-4B0D-84E8-98AE3E93F06F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6F6B4A21-8F39-4B0D-84E8-98AE3E93F06F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6F6B4A21-8F39-4B0D-84E8-98AE3E93F06F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6F6B4A21-8F39-4B0D-84E8-98AE3E93F06F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {BC95D91C-1F6B-4E3A-9DC6-49EDFB018CDE} + EndGlobalSection +EndGlobal diff --git a/Main.cs b/Main.cs new file mode 100644 index 0000000..22bdb27 --- /dev/null +++ b/Main.cs @@ -0,0 +1,6 @@ +using System.Data; +using Milimoe.FunGame.Testing.Solutions; + +DataTable dt = DataTableSolution.GetDataTable(); + +Console.WriteLine(dt.Rows[0]["Name"]); \ No newline at end of file diff --git a/Solutions/DataTable.cs b/Solutions/DataTable.cs new file mode 100644 index 0000000..9428466 --- /dev/null +++ b/Solutions/DataTable.cs @@ -0,0 +1,27 @@ +using System.Data; +using System.Text.Json; +using Milimoe.FunGame.Core.Model; + +namespace Milimoe.FunGame.Testing.Solutions +{ + public class DataTableSolution + { + public static DataTable GetDataTable() + { + DataTable dt = new(); + dt.Columns.Add(new DataColumn("ID", typeof(int))); + dt.Columns.Add(new DataColumn("Name", typeof(string))); + DataRow dr = dt.NewRow(); + dr["ID"] = 1; + dr["Name"] = "Mili"; + dt.Rows.Add(dr); + + JsonObject2 jsonobj = new(); + + string json = JsonSerializer.Serialize(dt, jsonobj.Options); + DataTable? dt2 = JsonSerializer.Deserialize(json, jsonobj.Options); + + return dt2 ?? new(); + } + } +}