diff --git a/.github/workflows/codebreaker-lib-client-stable.yml b/.github/workflows/codebreaker-lib-client-stable.yml index f81e6c46..531cba7f 100644 --- a/.github/workflows/codebreaker-lib-client-stable.yml +++ b/.github/workflows/codebreaker-lib-client-stable.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest env: solutionfile-path: src/Codebreaker.GameAPIs.Client.sln - projectfile-path: src/clients/common/Codebreaker.GameAPIs.Client/Codebreaker.GameAPIs.Client.csproj + projectfile-path: src/clients/Codebreaker.GameAPIs.Client/Codebreaker.GameAPIs.Client.csproj artifact-name: codebreaker-client-stable steps: diff --git a/.github/workflows/codebreaker-lib-client.yml b/.github/workflows/codebreaker-lib-client.yml index ef62656d..8f40d4d9 100644 --- a/.github/workflows/codebreaker-lib-client.yml +++ b/.github/workflows/codebreaker-lib-client.yml @@ -7,8 +7,8 @@ on: branches: [ main ] paths: - - 'src/clients/common/Codebreaker.GameAPIs.Client/**' - - 'src/clients/common/Codebreaker.GameAPIs.Client.Tests/**' + - 'src/clients/Codebreaker.GameAPIs.Client/**' + - 'src/clients/Codebreaker.GameAPIs.Client.Tests/**' - 'src/Codebreaker.GameA.sln' - '.github/workflows/codebreaker-lib-client.yml' - '.github/workflows/createnuget-withbuildnumber.yml' diff --git a/src/CodeBreaker.Bot.sln b/src/CodeBreaker.Bot.sln deleted file mode 100644 index e52ebcc4..00000000 --- a/src/CodeBreaker.Bot.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.2.32317.152 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CodeBreaker.Bot", "services\bot\CodeBreaker.Bot\CodeBreaker.Bot.csproj", "{FAC1E880-2F77-4295-95B9-0280AFDAE319}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CodeBreaker.Bot.Tests", "services\bot\CodeBreaker.Bot.Tests\CodeBreaker.Bot.Tests.csproj", "{996B6FDF-23A1-4980-BD1A-A742F04F3FA6}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {FAC1E880-2F77-4295-95B9-0280AFDAE319}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FAC1E880-2F77-4295-95B9-0280AFDAE319}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FAC1E880-2F77-4295-95B9-0280AFDAE319}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FAC1E880-2F77-4295-95B9-0280AFDAE319}.Release|Any CPU.Build.0 = Release|Any CPU - {996B6FDF-23A1-4980-BD1A-A742F04F3FA6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {996B6FDF-23A1-4980-BD1A-A742F04F3FA6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {996B6FDF-23A1-4980-BD1A-A742F04F3FA6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {996B6FDF-23A1-4980-BD1A-A742F04F3FA6}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {345AB8C6-E2BF-49AE-9215-09F50A6E3B71} - EndGlobalSection -EndGlobal diff --git a/src/CodeBreaker.Live.sln b/src/CodeBreaker.Live.sln deleted file mode 100644 index dbb9582f..00000000 --- a/src/CodeBreaker.Live.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.3.32611.2 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CodeBreaker.LiveService", "services\live\CodeBreaker.LiveService\CodeBreaker.LiveService.csproj", "{A7BCCEE2-9D5C-4C3E-AD51-F8774C908066}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {A7BCCEE2-9D5C-4C3E-AD51-F8774C908066}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A7BCCEE2-9D5C-4C3E-AD51-F8774C908066}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A7BCCEE2-9D5C-4C3E-AD51-F8774C908066}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A7BCCEE2-9D5C-4C3E-AD51-F8774C908066}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {ADE6E668-48D9-4552-BFF0-913542B21861} - EndGlobalSection -EndGlobal diff --git a/src/CodeBreaker.Shared.sln b/src/CodeBreaker.Shared.sln deleted file mode 100644 index 6a66dd9f..00000000 --- a/src/CodeBreaker.Shared.sln +++ /dev/null @@ -1,27 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.0.31903.59 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "shared", "shared", "{843045BA-0DD3-4DE1-8F25-404162040E19}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeBreaker.Shared", "shared\CodeBreaker.Shared\CodeBreaker.Shared.csproj", "{71737126-2FF3-4DFD-B9B5-25CC38303B95}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {71737126-2FF3-4DFD-B9B5-25CC38303B95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {71737126-2FF3-4DFD-B9B5-25CC38303B95}.Debug|Any CPU.Build.0 = Debug|Any CPU - {71737126-2FF3-4DFD-B9B5-25CC38303B95}.Release|Any CPU.ActiveCfg = Release|Any CPU - {71737126-2FF3-4DFD-B9B5-25CC38303B95}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {71737126-2FF3-4DFD-B9B5-25CC38303B95} = {843045BA-0DD3-4DE1-8F25-404162040E19} - EndGlobalSection -EndGlobal diff --git a/src/CodeBreaker.UserService.sln b/src/CodeBreaker.UserService.sln deleted file mode 100644 index 409a2bd8..00000000 --- a/src/CodeBreaker.UserService.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.5.33103.201 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CodeBreaker.UserService", "services\user\CodeBreaker.UserService\CodeBreaker.UserService.csproj", "{5CFE6FE4-6463-4BFC-8E82-AF9A0B7262DA}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {5CFE6FE4-6463-4BFC-8E82-AF9A0B7262DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5CFE6FE4-6463-4BFC-8E82-AF9A0B7262DA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5CFE6FE4-6463-4BFC-8E82-AF9A0B7262DA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5CFE6FE4-6463-4BFC-8E82-AF9A0B7262DA}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {CC457BB7-ACDA-4327-9124-82785E43C8C6} - EndGlobalSection -EndGlobal diff --git a/src/Codebreaker.GameAPIs.Client.sln b/src/Codebreaker.GameAPIs.Client.sln index dcf5047e..4bbb4197 100644 --- a/src/Codebreaker.GameAPIs.Client.sln +++ b/src/Codebreaker.GameAPIs.Client.sln @@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.7.33913.275 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Codebreaker.GameAPIs.Client", "clients\common\Codebreaker.GameAPIs.Client\Codebreaker.GameAPIs.Client.csproj", "{87B3D527-0BB4-4B7E-9A29-525F86836FBD}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Codebreaker.GameAPIs.Client", "clients\Codebreaker.GameAPIs.Client\Codebreaker.GameAPIs.Client.csproj", "{11AEC509-CB22-441A-B6A0-19732DA0F0F8}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Codebreaker.GameAPIs.Client.Tests", "clients\common\Codebreaker.GameAPIs.Client.Tests\Codebreaker.GameAPIs.Client.Tests.csproj", "{D6A22A41-9853-4EDE-8B25-033308390292}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Codebreaker.GameAPIs.Client.Tests", "clients\Codebreaker.GameAPIs.Client.Tests\Codebreaker.GameAPIs.Client.Tests.csproj", "{EF2D1638-A6FA-4FF1-88BD-CFAADDE80E37}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -13,14 +13,14 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {87B3D527-0BB4-4B7E-9A29-525F86836FBD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {87B3D527-0BB4-4B7E-9A29-525F86836FBD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {87B3D527-0BB4-4B7E-9A29-525F86836FBD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {87B3D527-0BB4-4B7E-9A29-525F86836FBD}.Release|Any CPU.Build.0 = Release|Any CPU - {D6A22A41-9853-4EDE-8B25-033308390292}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D6A22A41-9853-4EDE-8B25-033308390292}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D6A22A41-9853-4EDE-8B25-033308390292}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D6A22A41-9853-4EDE-8B25-033308390292}.Release|Any CPU.Build.0 = Release|Any CPU + {11AEC509-CB22-441A-B6A0-19732DA0F0F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {11AEC509-CB22-441A-B6A0-19732DA0F0F8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {11AEC509-CB22-441A-B6A0-19732DA0F0F8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {11AEC509-CB22-441A-B6A0-19732DA0F0F8}.Release|Any CPU.Build.0 = Release|Any CPU + {EF2D1638-A6FA-4FF1-88BD-CFAADDE80E37}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EF2D1638-A6FA-4FF1-88BD-CFAADDE80E37}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EF2D1638-A6FA-4FF1-88BD-CFAADDE80E37}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EF2D1638-A6FA-4FF1-88BD-CFAADDE80E37}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/Codebreaker.GameApis.sln b/src/Codebreaker.GameApis.sln deleted file mode 100644 index ed90e1cc..00000000 --- a/src/Codebreaker.GameApis.sln +++ /dev/null @@ -1,67 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.0.31903.59 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "services", "services", "{0FB1B986-E087-4C76-8FF8-B68B703F39B0}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gameapi", "gameapi", "{58E2F579-8F0B-424D-B965-68FDBDB30F47}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Codebreaker.Data.Cosmos", "services\gameapi\Codebreaker.Data.Cosmos\Codebreaker.Data.Cosmos.csproj", "{E437B6EA-C5D9-4978-A82C-6F46FEC2A783}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Codebreaker.Data.SqlServer", "services\gameapi\Codebreaker.Data.SqlServer\Codebreaker.Data.SqlServer.csproj", "{E6EEB9B3-E223-4C2B-B69F-504F4038FA77}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Codebreaker.Data.SqlServer.Tests", "services\gameapi\Codebreaker.Data.SqlServer.Tests\Codebreaker.Data.SqlServer.Tests.csproj", "{9A381BB0-88AE-40B3-8703-7CDBDC4D7C22}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Codebreaker.GameAPIs", "services\gameapi\Codebreaker.GameAPIs\Codebreaker.GameAPIs.csproj", "{FE97466C-C996-4652-88E5-98B6EAA261C3}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Codebreaker.GameAPIs.Models", "services\gameapi\Codebreaker.GameAPIs.Models\Codebreaker.GameAPIs.Models.csproj", "{D53C9ACA-6AF5-4404-AA85-7C03FB3ABA01}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Codebreaker.GameAPIs.Tests", "services\gameapi\Codebreaker.GameAPIs.Tests\Codebreaker.GameAPIs.Tests.csproj", "{2A6EDB3B-B79E-49D3-A92B-C8A81E48F65F}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E437B6EA-C5D9-4978-A82C-6F46FEC2A783}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E437B6EA-C5D9-4978-A82C-6F46FEC2A783}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E437B6EA-C5D9-4978-A82C-6F46FEC2A783}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E437B6EA-C5D9-4978-A82C-6F46FEC2A783}.Release|Any CPU.Build.0 = Release|Any CPU - {E6EEB9B3-E223-4C2B-B69F-504F4038FA77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E6EEB9B3-E223-4C2B-B69F-504F4038FA77}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E6EEB9B3-E223-4C2B-B69F-504F4038FA77}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E6EEB9B3-E223-4C2B-B69F-504F4038FA77}.Release|Any CPU.Build.0 = Release|Any CPU - {9A381BB0-88AE-40B3-8703-7CDBDC4D7C22}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9A381BB0-88AE-40B3-8703-7CDBDC4D7C22}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9A381BB0-88AE-40B3-8703-7CDBDC4D7C22}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9A381BB0-88AE-40B3-8703-7CDBDC4D7C22}.Release|Any CPU.Build.0 = Release|Any CPU - {FE97466C-C996-4652-88E5-98B6EAA261C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FE97466C-C996-4652-88E5-98B6EAA261C3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FE97466C-C996-4652-88E5-98B6EAA261C3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FE97466C-C996-4652-88E5-98B6EAA261C3}.Release|Any CPU.Build.0 = Release|Any CPU - {D53C9ACA-6AF5-4404-AA85-7C03FB3ABA01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D53C9ACA-6AF5-4404-AA85-7C03FB3ABA01}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D53C9ACA-6AF5-4404-AA85-7C03FB3ABA01}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D53C9ACA-6AF5-4404-AA85-7C03FB3ABA01}.Release|Any CPU.Build.0 = Release|Any CPU - {2A6EDB3B-B79E-49D3-A92B-C8A81E48F65F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2A6EDB3B-B79E-49D3-A92B-C8A81E48F65F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2A6EDB3B-B79E-49D3-A92B-C8A81E48F65F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2A6EDB3B-B79E-49D3-A92B-C8A81E48F65F}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {58E2F579-8F0B-424D-B965-68FDBDB30F47} = {0FB1B986-E087-4C76-8FF8-B68B703F39B0} - {E437B6EA-C5D9-4978-A82C-6F46FEC2A783} = {58E2F579-8F0B-424D-B965-68FDBDB30F47} - {E6EEB9B3-E223-4C2B-B69F-504F4038FA77} = {58E2F579-8F0B-424D-B965-68FDBDB30F47} - {9A381BB0-88AE-40B3-8703-7CDBDC4D7C22} = {58E2F579-8F0B-424D-B965-68FDBDB30F47} - {FE97466C-C996-4652-88E5-98B6EAA261C3} = {58E2F579-8F0B-424D-B965-68FDBDB30F47} - {D53C9ACA-6AF5-4404-AA85-7C03FB3ABA01} = {58E2F579-8F0B-424D-B965-68FDBDB30F47} - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {18EADE0D-2496-4DD6-B225-A2BC1D4EDB68} - EndGlobalSection -EndGlobal diff --git a/src/clients/common/Codebreaker.GameAPIs.Client.Tests/Codebreaker.GameAPIs.Client.Tests.csproj b/src/clients/Codebreaker.GameAPIs.Client.Tests/Codebreaker.GameAPIs.Client.Tests.csproj similarity index 100% rename from src/clients/common/Codebreaker.GameAPIs.Client.Tests/Codebreaker.GameAPIs.Client.Tests.csproj rename to src/clients/Codebreaker.GameAPIs.Client.Tests/Codebreaker.GameAPIs.Client.Tests.csproj diff --git a/src/clients/common/Codebreaker.GameAPIs.Client.Tests/GamesClientTests.cs b/src/clients/Codebreaker.GameAPIs.Client.Tests/GamesClientTests.cs similarity index 100% rename from src/clients/common/Codebreaker.GameAPIs.Client.Tests/GamesClientTests.cs rename to src/clients/Codebreaker.GameAPIs.Client.Tests/GamesClientTests.cs diff --git a/src/clients/common/Codebreaker.GameAPIs.Client.Tests/GlobalUsings.cs b/src/clients/Codebreaker.GameAPIs.Client.Tests/GlobalUsings.cs similarity index 100% rename from src/clients/common/Codebreaker.GameAPIs.Client.Tests/GlobalUsings.cs rename to src/clients/Codebreaker.GameAPIs.Client.Tests/GlobalUsings.cs diff --git a/src/clients/common/Codebreaker.GameAPIs.Client/ActivityExtensions.cs b/src/clients/Codebreaker.GameAPIs.Client/ActivityExtensions.cs similarity index 100% rename from src/clients/common/Codebreaker.GameAPIs.Client/ActivityExtensions.cs rename to src/clients/Codebreaker.GameAPIs.Client/ActivityExtensions.cs diff --git a/src/clients/common/Codebreaker.GameAPIs.Client/Codebreaker.GameAPIs.Client.csproj b/src/clients/Codebreaker.GameAPIs.Client/Codebreaker.GameAPIs.Client.csproj similarity index 100% rename from src/clients/common/Codebreaker.GameAPIs.Client/Codebreaker.GameAPIs.Client.csproj rename to src/clients/Codebreaker.GameAPIs.Client/Codebreaker.GameAPIs.Client.csproj diff --git a/src/clients/common/Codebreaker.GameAPIs.Client/GamesClient.cs b/src/clients/Codebreaker.GameAPIs.Client/GamesClient.cs similarity index 100% rename from src/clients/common/Codebreaker.GameAPIs.Client/GamesClient.cs rename to src/clients/Codebreaker.GameAPIs.Client/GamesClient.cs diff --git a/src/clients/common/Codebreaker.GameAPIs.Client/GlobalUsings.cs b/src/clients/Codebreaker.GameAPIs.Client/GlobalUsings.cs similarity index 100% rename from src/clients/common/Codebreaker.GameAPIs.Client/GlobalUsings.cs rename to src/clients/Codebreaker.GameAPIs.Client/GlobalUsings.cs diff --git a/src/clients/common/Codebreaker.GameAPIs.Client/IGamesClient.cs b/src/clients/Codebreaker.GameAPIs.Client/IGamesClient.cs similarity index 100% rename from src/clients/common/Codebreaker.GameAPIs.Client/IGamesClient.cs rename to src/clients/Codebreaker.GameAPIs.Client/IGamesClient.cs diff --git a/src/clients/common/Codebreaker.GameAPIs.Client/Images/codebreaker.jpeg b/src/clients/Codebreaker.GameAPIs.Client/Images/codebreaker.jpeg similarity index 100% rename from src/clients/common/Codebreaker.GameAPIs.Client/Images/codebreaker.jpeg rename to src/clients/Codebreaker.GameAPIs.Client/Images/codebreaker.jpeg diff --git a/src/clients/common/Codebreaker.GameAPIs.Client/Log.cs b/src/clients/Codebreaker.GameAPIs.Client/Log.cs similarity index 100% rename from src/clients/common/Codebreaker.GameAPIs.Client/Log.cs rename to src/clients/Codebreaker.GameAPIs.Client/Log.cs diff --git a/src/clients/common/Codebreaker.GameAPIs.Client/Models/CreateGameRequest.cs b/src/clients/Codebreaker.GameAPIs.Client/Models/CreateGameRequest.cs similarity index 100% rename from src/clients/common/Codebreaker.GameAPIs.Client/Models/CreateGameRequest.cs rename to src/clients/Codebreaker.GameAPIs.Client/Models/CreateGameRequest.cs diff --git a/src/clients/common/Codebreaker.GameAPIs.Client/Models/CreateGameResponse.cs b/src/clients/Codebreaker.GameAPIs.Client/Models/CreateGameResponse.cs similarity index 100% rename from src/clients/common/Codebreaker.GameAPIs.Client/Models/CreateGameResponse.cs rename to src/clients/Codebreaker.GameAPIs.Client/Models/CreateGameResponse.cs diff --git a/src/clients/common/Codebreaker.GameAPIs.Client/Models/GameInfo.cs b/src/clients/Codebreaker.GameAPIs.Client/Models/GameInfo.cs similarity index 100% rename from src/clients/common/Codebreaker.GameAPIs.Client/Models/GameInfo.cs rename to src/clients/Codebreaker.GameAPIs.Client/Models/GameInfo.cs diff --git a/src/clients/common/Codebreaker.GameAPIs.Client/Models/GamesQuery.cs b/src/clients/Codebreaker.GameAPIs.Client/Models/GamesQuery.cs similarity index 100% rename from src/clients/common/Codebreaker.GameAPIs.Client/Models/GamesQuery.cs rename to src/clients/Codebreaker.GameAPIs.Client/Models/GamesQuery.cs diff --git a/src/clients/common/Codebreaker.GameAPIs.Client/Models/MoveInfo.cs b/src/clients/Codebreaker.GameAPIs.Client/Models/MoveInfo.cs similarity index 100% rename from src/clients/common/Codebreaker.GameAPIs.Client/Models/MoveInfo.cs rename to src/clients/Codebreaker.GameAPIs.Client/Models/MoveInfo.cs diff --git a/src/clients/common/Codebreaker.GameAPIs.Client/Models/UpdateGameRequest.cs b/src/clients/Codebreaker.GameAPIs.Client/Models/UpdateGameRequest.cs similarity index 100% rename from src/clients/common/Codebreaker.GameAPIs.Client/Models/UpdateGameRequest.cs rename to src/clients/Codebreaker.GameAPIs.Client/Models/UpdateGameRequest.cs diff --git a/src/clients/common/Codebreaker.GameAPIs.Client/Models/UpdateGameResponse.cs b/src/clients/Codebreaker.GameAPIs.Client/Models/UpdateGameResponse.cs similarity index 100% rename from src/clients/common/Codebreaker.GameAPIs.Client/Models/UpdateGameResponse.cs rename to src/clients/Codebreaker.GameAPIs.Client/Models/UpdateGameResponse.cs diff --git a/src/clients/common/Codebreaker.GameAPIs.Client/docs/readme.md b/src/clients/Codebreaker.GameAPIs.Client/docs/readme.md similarity index 100% rename from src/clients/common/Codebreaker.GameAPIs.Client/docs/readme.md rename to src/clients/Codebreaker.GameAPIs.Client/docs/readme.md diff --git a/src/clients/shared/CodeBreaker.Services/Authentication/AuthService.cs b/src/clients/shared/CodeBreaker.Services/Authentication/AuthService.cs deleted file mode 100644 index 81b9a681..00000000 --- a/src/clients/shared/CodeBreaker.Services/Authentication/AuthService.cs +++ /dev/null @@ -1,148 +0,0 @@ -using CodeBreaker.Services.Authentication.Definitions; -using CodeBreaker.Services.EventArguments; -using CodeBreaker.Services.Options; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; -using Microsoft.Identity.Client; -using Microsoft.Identity.Client.Extensions.Msal; - -namespace CodeBreaker.Services.Authentication; - -public class AuthService : IAuthService -{ - private readonly AuthOptions _authOptions; - - private string TenantName => _authOptions.TenantName; - - private string Tenant => $"{TenantName}.onmicrosoft.com"; - - private string AzureAdB2CHostname => $"{TenantName}.b2clogin.com"; - - private string RedirectUri => _authOptions.RedirectUri; - - private string AuthorityBase => $"https://{AzureAdB2CHostname}/tfp/{Tenant}/"; - - private string AuthoritySignUpSignIn => $"{AuthorityBase}{_authOptions.Policies.SignUpSignInPolicy}"; - - private string AuthoritySignUp=> $"{AuthorityBase}{_authOptions.Policies.SignUpPolicy}"; - - private string AuthoritySignIn => $"{AuthorityBase}{_authOptions.Policies.SignInPolicy}"; - - private string AuthorityEditProfile => $"{AuthorityBase}{_authOptions.Policies.EditProfilePolicy}"; - - private string AuthorityResetPassword => $"{AuthorityBase}{_authOptions.Policies.ResetPasswordPolicy}"; - - private readonly static string PersistentTokenCacheDirectory = Path.Combine(MsalCacheHelper.UserRootDirectory, ".codebreaker"); - - private readonly static string PersistentTokenCacheFileName = "codebreaker_token_cache.txt"; - - private readonly ILogger _logger; - - private readonly IPublicClientApplication _publicClientApplication; - - private UserInformation? _lastUserInformation; - - public event EventHandler? OnAuthenticationStateChanged; - - public AuthService(ILogger logger, IOptions authOptions) - { - _logger = logger ?? throw new ArgumentNullException(nameof(logger)); - _authOptions = authOptions.Value; - _publicClientApplication = PublicClientApplicationBuilder.Create(_authOptions.ClientId) - .WithB2CAuthority(AuthoritySignUpSignIn) - .WithRedirectUri(RedirectUri) - //.WithLogging(Log, LogLevel.Info, false) // don't log P(ersonally) I(dentifiable) I(nformation) details on a regular basis - .Build(); - } - - public async Task RegisterPersistentTokenCacheAsync() - { - var storageProperties = new StorageCreationPropertiesBuilder(PersistentTokenCacheFileName, PersistentTokenCacheDirectory).Build(); - var cacheHelper = await MsalCacheHelper.CreateAsync(storageProperties); - cacheHelper.RegisterCache(_publicClientApplication.UserTokenCache); - } - - public UserInformation? LastUserInformation - { - get => _lastUserInformation; - private set - { - _lastUserInformation = value; - OnAuthenticationStateChanged?.Invoke(this, new()); - } - } - - public bool IsAuthenticated => LastUserInformation is not null; - - public async Task TryAquireTokenSilentlyAsync(IAuthDefinition authDefinition, CancellationToken cancellationToken = default) - { - IAccount? account = (await GetAccountsAsync(cancellationToken)).FirstOrDefault(); - - try - { - AuthenticationResult result = await _publicClientApplication.AcquireTokenSilent(authDefinition.Claims, account).ExecuteAsync(cancellationToken); - LastUserInformation = UserInformation.FromAuthenticationResult(result); - return true; - } - catch (MsalUiRequiredException) - { - return false; - } - catch (Exception ex) - { - _logger.LogError(ex, "Unable to aquire token silently."); - throw; - } - } - - public async Task AquireTokenAsync(IAuthDefinition authDefinition, CancellationToken cancellationToken = default) - { - IAccount? account = (await GetAccountsAsync(cancellationToken)).FirstOrDefault(); - - try - { - AuthenticationResult result = await _publicClientApplication.AcquireTokenSilent(authDefinition.Claims, account).ExecuteAsync(cancellationToken); - LastUserInformation = UserInformation.FromAuthenticationResult(result); - return result; - } - catch (MsalUiRequiredException) - { - _logger.LogInformation("Unable to aquire token silently. Continueing interactively..."); - - try - { - AuthenticationResult result = await _publicClientApplication - .AcquireTokenInteractive(authDefinition.Claims) - .ExecuteAsync(cancellationToken); - LastUserInformation = UserInformation.FromAuthenticationResult(result); - return result; - } - catch (MsalException msalEx) - { - _logger.LogError(msalEx, "Unable to aquire token interactively."); - throw; - } - } - catch (Exception ex) - { - _logger.LogError(ex, "Unable to aquire token silently."); - throw; - } - } - - public async Task LogoutAsync(CancellationToken cancellationToken = default) - { - var accounts = await GetAccountsAsync(cancellationToken); - - foreach (var account in accounts) - await _publicClientApplication.RemoveAsync(account); - - LastUserInformation = null; - } - - private Task> GetAccountsAsync(CancellationToken cancellation = default) - { - cancellation.ThrowIfCancellationRequested(); - return _publicClientApplication.GetAccountsAsync(_authOptions.Policies.SignUpSignInPolicy); - } -} diff --git a/src/clients/shared/CodeBreaker.Services/Authentication/Definitions/ApiServiceAuthDefinition.cs b/src/clients/shared/CodeBreaker.Services/Authentication/Definitions/ApiServiceAuthDefinition.cs deleted file mode 100644 index 9834a0f2..00000000 --- a/src/clients/shared/CodeBreaker.Services/Authentication/Definitions/ApiServiceAuthDefinition.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace CodeBreaker.Services.Authentication.Definitions; - -public class ApiServiceAuthDefinition : IAuthDefinition -{ - public IEnumerable Claims { get; private init; } = new[] { - $"https://codebreaker3000.onmicrosoft.com/39a665a4-54ce-44cd-b581-0f654a31dbcf/Games.Play", - $"https://codebreaker3000.onmicrosoft.com/39a665a4-54ce-44cd-b581-0f654a31dbcf/Reports.Read", - }; -} diff --git a/src/clients/shared/CodeBreaker.Services/Authentication/Definitions/IAuthDefinition.cs b/src/clients/shared/CodeBreaker.Services/Authentication/Definitions/IAuthDefinition.cs deleted file mode 100644 index 45cab52d..00000000 --- a/src/clients/shared/CodeBreaker.Services/Authentication/Definitions/IAuthDefinition.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace CodeBreaker.Services.Authentication.Definitions; - -public interface IAuthDefinition -{ - IEnumerable Claims { get; } -} diff --git a/src/clients/shared/CodeBreaker.Services/Authentication/Definitions/LiveServiceAuthDefinition.cs b/src/clients/shared/CodeBreaker.Services/Authentication/Definitions/LiveServiceAuthDefinition.cs deleted file mode 100644 index 9fc3d881..00000000 --- a/src/clients/shared/CodeBreaker.Services/Authentication/Definitions/LiveServiceAuthDefinition.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace CodeBreaker.Services.Authentication.Definitions; - -public class LiveServiceAuthDefinition : IAuthDefinition -{ - public IEnumerable Claims { get; private init; } = new[] { - $"https://codebreaker3000.onmicrosoft.com/77d424b0-f92c-4f00-bd88-c6645f0d11e7/Messages.ReadFromAllGroups", - $"https://codebreaker3000.onmicrosoft.com/77d424b0-f92c-4f00-bd88-c6645f0d11e7/Messages.ReadFromSameGroup", - }; -} diff --git a/src/clients/shared/CodeBreaker.Services/Authentication/IAuthService.cs b/src/clients/shared/CodeBreaker.Services/Authentication/IAuthService.cs deleted file mode 100644 index 35d4a0ff..00000000 --- a/src/clients/shared/CodeBreaker.Services/Authentication/IAuthService.cs +++ /dev/null @@ -1,22 +0,0 @@ -using CodeBreaker.Services.Authentication.Definitions; -using CodeBreaker.Services.EventArguments; -using Microsoft.Identity.Client; - -namespace CodeBreaker.Services.Authentication; - -public interface IAuthService -{ - event EventHandler? OnAuthenticationStateChanged; - - UserInformation? LastUserInformation { get; } - - bool IsAuthenticated { get; } - - Task RegisterPersistentTokenCacheAsync(); - - Task TryAquireTokenSilentlyAsync(IAuthDefinition authDefinition, CancellationToken cancellationToken = default); - - Task AquireTokenAsync(IAuthDefinition authHandler, CancellationToken cancellation = default); - - Task LogoutAsync(CancellationToken cancellationToken = default); -} diff --git a/src/clients/shared/CodeBreaker.Services/Authentication/MissingClaimException.cs b/src/clients/shared/CodeBreaker.Services/Authentication/MissingClaimException.cs deleted file mode 100644 index df771e27..00000000 --- a/src/clients/shared/CodeBreaker.Services/Authentication/MissingClaimException.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace CodeBreaker.Services.Authentication; - -public class MissingClaimException : Exception -{ - public MissingClaimException(string? missingClaim) - { - MissingClaim = missingClaim; - } - - public string? MissingClaim { get; init; } -} diff --git a/src/clients/shared/CodeBreaker.Services/Authentication/UserInformation.cs b/src/clients/shared/CodeBreaker.Services/Authentication/UserInformation.cs deleted file mode 100644 index b2c58787..00000000 --- a/src/clients/shared/CodeBreaker.Services/Authentication/UserInformation.cs +++ /dev/null @@ -1,26 +0,0 @@ -using Microsoft.Identity.Client; - -namespace CodeBreaker.Services.Authentication; - -public record UserInformation( - IAccount Account, - IEnumerable EmailAddresses, - string FirstName, - string LastName, - string GamerName -) -{ - public static UserInformation FromAuthenticationResult(AuthenticationResult authenticationResult) - { - string? GetClaim(string type) => authenticationResult.ClaimsPrincipal.Claims.SingleOrDefault(x => x.Type == type)?.Value; - return new( - authenticationResult.Account, - GetClaim("emails")?.Split(',') ?? throw new MissingClaimException("emails"), - GetClaim("given_name") ?? throw new MissingClaimException("given_name"), - GetClaim("family_name") ?? throw new MissingClaimException("family_name"), - GetClaim("extension_GamerName") ?? throw new MissingClaimException("extension_GamerName") - ); - } - - public string FullName => $"{FirstName} {LastName}"; -} diff --git a/src/clients/shared/CodeBreaker.Services/CodeBreaker.Services.csproj b/src/clients/shared/CodeBreaker.Services/CodeBreaker.Services.csproj deleted file mode 100644 index d11e199c..00000000 --- a/src/clients/shared/CodeBreaker.Services/CodeBreaker.Services.csproj +++ /dev/null @@ -1,28 +0,0 @@ - - - - net6.0;net7.0 - enable - enable - Debug;Release;Mudblazor;FastUI - - - - CNInnovation.Codebreaker.Services - CN innovation - CN innovation - - Codebreaker client library to access the Game API and the Live Services API with GameClient and LiveClient - - https://github.com/CNinnovation/codebreakerpackages - - - - - - - - - - - diff --git a/src/clients/shared/CodeBreaker.Services/EventArguments/ILiveEventArgs.cs b/src/clients/shared/CodeBreaker.Services/EventArguments/ILiveEventArgs.cs deleted file mode 100644 index 3853362e..00000000 --- a/src/clients/shared/CodeBreaker.Services/EventArguments/ILiveEventArgs.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace CodeBreaker.Services.EventArguments; - -public interface ILiveEventArgs -{ - public T Data { get; init; } -} diff --git a/src/clients/shared/CodeBreaker.Services/EventArguments/OnAuthenticationStateChangedEventArgs.cs b/src/clients/shared/CodeBreaker.Services/EventArguments/OnAuthenticationStateChangedEventArgs.cs deleted file mode 100644 index 0818a449..00000000 --- a/src/clients/shared/CodeBreaker.Services/EventArguments/OnAuthenticationStateChangedEventArgs.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace CodeBreaker.Services.EventArguments; - -public class OnAuthenticationStateChangedEventArgs : EventArgs -{ -} diff --git a/src/clients/shared/CodeBreaker.Services/EventArguments/OnGameEventArgs.cs b/src/clients/shared/CodeBreaker.Services/EventArguments/OnGameEventArgs.cs deleted file mode 100644 index 164cb8d7..00000000 --- a/src/clients/shared/CodeBreaker.Services/EventArguments/OnGameEventArgs.cs +++ /dev/null @@ -1,8 +0,0 @@ -using CodeBreaker.Shared.Models.Live.EventPayloads; - -namespace CodeBreaker.Services.EventArguments; - -public class OnGameEventArgs : EventArgs, ILiveEventArgs -{ - public GameCreatedPayload? Data { get; init; } -} diff --git a/src/clients/shared/CodeBreaker.Services/EventArguments/OnMoveEventArgs.cs b/src/clients/shared/CodeBreaker.Services/EventArguments/OnMoveEventArgs.cs deleted file mode 100644 index 92b4dc1b..00000000 --- a/src/clients/shared/CodeBreaker.Services/EventArguments/OnMoveEventArgs.cs +++ /dev/null @@ -1,8 +0,0 @@ -using CodeBreaker.Shared.Models.Live.EventPayloads; - -namespace CodeBreaker.Services.EventArguments; - -public class OnMoveEventArgs : EventArgs, ILiveEventArgs -{ - public MoveCreatedPayload? Data { get; init; } -} diff --git a/src/clients/shared/CodeBreaker.Services/GameClient.cs b/src/clients/shared/CodeBreaker.Services/GameClient.cs deleted file mode 100644 index c77e1a33..00000000 --- a/src/clients/shared/CodeBreaker.Services/GameClient.cs +++ /dev/null @@ -1,87 +0,0 @@ -using CodeBreaker.Services.Authentication; -using CodeBreaker.Services.Authentication.Definitions; -using CodeBreaker.Shared.Models.Api; -using Microsoft.Extensions.Logging; - -using System.Net.Http.Json; - -namespace CodeBreaker.Services; - -public class GameClient : IGameClient, IGameReportClient -{ - private readonly HttpClient _httpClient; - - private readonly ILogger _logger; - - private readonly IAuthService _authService; - - private readonly IAuthDefinition _authDefinition = new ApiServiceAuthDefinition(); - - public GameClient(HttpClient httpClient, ILogger logger, IAuthService authService) - { - _httpClient = httpClient; - _logger = logger; - _authService = authService; - _logger.LogInformation("Injected HttpClient with base address {uri} into GameClient", _httpClient.BaseAddress); - } - - public async Task StartGameAsync(string username, string gameType) - { - await SetAuthentication(); - CreateGameRequest request = new(username, gameType); - HttpResponseMessage responseMessage = await _httpClient.PostAsJsonAsync("/games", request); - responseMessage.EnsureSuccessStatusCode(); - return await responseMessage.Content.ReadFromJsonAsync(); - } - - public async Task CancelGameAsync(Guid gameId) - { - await SetAuthentication(); - HttpResponseMessage responseMessage = await _httpClient.DeleteAsync($"/games/{gameId}?cancel=true"); - responseMessage.EnsureSuccessStatusCode(); - } - - public async Task SetMoveAsync(Guid gameId, params string[] colorNames) - { - await SetAuthentication(); - CreateMoveRequest request = new CreateMoveRequest(colorNames.ToList()); - HttpResponseMessage responseMessage = await _httpClient.PostAsJsonAsync($"/games/{gameId}/moves", request); - responseMessage.EnsureSuccessStatusCode(); - return await responseMessage.Content.ReadFromJsonAsync(); - } - - public async Task GetGamesAsync(DateTime? date) - { - await SetAuthentication(); - string requestUri = "/games"; - - if (date is null) - date = DateTime.Now.Date; - - requestUri = $"{requestUri}?date={date.Value.ToString("yyyy-MM-dd")}"; - _logger.LogInformation("Calling Codebreaker with {uri}", requestUri); - - return await _httpClient.GetFromJsonAsync(requestUri); - } - - public async Task GetGameAsync(Guid id) - { - await SetAuthentication(); - string requestUri = $"/games/{id}"; - _logger.LogInformation("Calling Codebreaker with {uri}", requestUri); - HttpResponseMessage responseMessage = await _httpClient.GetAsync(requestUri); - responseMessage.EnsureSuccessStatusCode(); - return await responseMessage.Content.ReadFromJsonAsync(); - } - - private async ValueTask SetAuthentication() - { - if (!_authService.IsAuthenticated) - return; - - _httpClient.DefaultRequestHeaders.Authorization = new("Bearer", await GetAccessTokenAsync()); - } - - private async Task GetAccessTokenAsync() => - (await _authService.AquireTokenAsync(_authDefinition)).AccessToken; -} diff --git a/src/clients/shared/CodeBreaker.Services/IGameClient.cs b/src/clients/shared/CodeBreaker.Services/IGameClient.cs deleted file mode 100644 index befb0748..00000000 --- a/src/clients/shared/CodeBreaker.Services/IGameClient.cs +++ /dev/null @@ -1,12 +0,0 @@ -using CodeBreaker.Shared.Models.Api; - -namespace CodeBreaker.Services; - -public interface IGameClient -{ - Task SetMoveAsync(Guid gameId, params string[] colorNames); - - Task StartGameAsync(string username, string gameType); - - Task CancelGameAsync(Guid gameId); -} diff --git a/src/clients/shared/CodeBreaker.Services/IGameReportClient.cs b/src/clients/shared/CodeBreaker.Services/IGameReportClient.cs deleted file mode 100644 index aa8d8490..00000000 --- a/src/clients/shared/CodeBreaker.Services/IGameReportClient.cs +++ /dev/null @@ -1,9 +0,0 @@ -using CodeBreaker.Shared.Models.Api; - -namespace CodeBreaker.Services; -public interface IGameReportClient -{ - Task GetGameAsync(Guid id); - - Task GetGamesAsync(DateTime? date); -} diff --git a/src/clients/shared/CodeBreaker.Services/IViewModelNavigationService.cs b/src/clients/shared/CodeBreaker.Services/IViewModelNavigationService.cs deleted file mode 100644 index f089c4e3..00000000 --- a/src/clients/shared/CodeBreaker.Services/IViewModelNavigationService.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace CodeBreaker.Services; - -public interface IViewModelNavigationService -{ - bool NavigateToViewModel(string viewModelKey, object? parameter = null, bool clearNavigation = false); - - bool NavigateToViewModel(Type viewModelType, object? parameter = default, bool clearNavigation = false) => - NavigateToViewModel(viewModelType?.FullName ?? throw new ArgumentNullException(nameof(viewModelType)), parameter, clearNavigation); - - bool GoBack(); -} diff --git a/src/clients/shared/CodeBreaker.Services/LiveClient.cs b/src/clients/shared/CodeBreaker.Services/LiveClient.cs deleted file mode 100644 index 1046f86e..00000000 --- a/src/clients/shared/CodeBreaker.Services/LiveClient.cs +++ /dev/null @@ -1,112 +0,0 @@ -using System.Text.Json; -using CodeBreaker.Services.Authentication; -using CodeBreaker.Services.Authentication.Definitions; -using CodeBreaker.Services.EventArguments; -using CodeBreaker.Shared.Models.Live; -using CodeBreaker.Shared.Models.Live.EventPayloads; -using Microsoft.AspNetCore.SignalR.Client; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; -using static CodeBreaker.Shared.Models.Live.LiveEventNames; - -namespace CodeBreaker.Services; - -public class LiveClientOptions -{ - public string LiveBase { get; set; } = string.Empty; -} - -public class LiveClient -{ - private readonly ILogger _logger; - - private readonly HubConnection _hubConnection; - - private readonly IAuthService _authService; - - private readonly IAuthDefinition _liveAuthDefinition = new LiveServiceAuthDefinition(); - - public event EventHandler? OnGameEvent; - - public event EventHandler? OnMoveEvent; - - private readonly Dictionary> _eventHandlers = new (); - - public LiveClient(ILogger logger, IOptions options, IAuthService authService) - { - _logger = logger; - _authService = authService; - _hubConnection = BuildHubConnection(options.Value.LiveBase); - InitializeEventHandlers(); - _hubConnection.On("gameEvent", OnRemoteEvent); - } - - private HubConnection BuildHubConnection(string liveBase) => - new HubConnectionBuilder() - .WithUrl(liveBase, options => - { - options.AccessTokenProvider = async () => (await _authService.AquireTokenAsync(_liveAuthDefinition)).AccessToken; - }) - .WithAutomaticReconnect() - .ConfigureLogging(x => - { - x.SetMinimumLevel(LogLevel.Information); - }) - .Build(); - - public Task StartAsync(CancellationToken token = default) - { - return _hubConnection.StartAsync(token); - } - - public IAsyncEnumerable SubscribeToEventsAsync(CancellationToken token = default) - { - if (_hubConnection.State != HubConnectionState.Connected) - throw new InvalidOperationException("The SignalR-Client has to be started before"); - - return _hubConnection.StreamAsync("SubscribeToGameEvents", token); - } - - private void OnRemoteEvent(LiveHubArgs args) - { - if (args is null || args.Name is null) - throw new ArgumentNullException(nameof(args)); - - if (!_eventHandlers.TryGetValue(args.Name, out Action? action)) - throw new ArgumentOutOfRangeException(nameof(args.Name), "No EventHandler for this eventName found."); - - action(args); - } - - private void InitializeEventHandlers() - { - _eventHandlers.Add(GameCreatedEventName, eventData => Handle(eventData, () => OnGameEvent)); - _eventHandlers.Add(MoveCreatedEventName, eventData => Handle(eventData, () => OnMoveEvent)); - } - - private void Handle(LiveHubArgs liveHubArgs, Func?> eventHandler) - where TArgs : ILiveEventArgs, new() - { - string? payloadString = liveHubArgs.Data.ToString(); - - if (payloadString is null) - { - _logger.LogInformation("EventPayload is null. Skipping event."); - return; - } - - T? data = JsonSerializer.Deserialize(payloadString); - - if (data is null) - { - _logger.LogInformation("EventData is null. Skipping event."); - return; - } - - TArgs args = new TArgs() - { - Data = data - }; - eventHandler()?.Invoke(this, args); - } -} diff --git a/src/clients/shared/CodeBreaker.Services/Options/AuthOptions.cs b/src/clients/shared/CodeBreaker.Services/Options/AuthOptions.cs deleted file mode 100644 index a35583f3..00000000 --- a/src/clients/shared/CodeBreaker.Services/Options/AuthOptions.cs +++ /dev/null @@ -1,25 +0,0 @@ -namespace CodeBreaker.Services.Options; - -public class AuthOptions -{ - public string TenantName { get; set; } = string.Empty; - - public string ClientId { get; set; } = string.Empty; - - public string RedirectUri { get; set; } = string.Empty; - - public AuthPolicyOptions Policies { get; set; } = new(); -} - -public class AuthPolicyOptions -{ - public string SignUpSignInPolicy { get; set; } = string.Empty; - - public string SignInPolicy { get; set; } = string.Empty; - - public string SignUpPolicy { get; set; } = string.Empty; - - public string EditProfilePolicy { get; set; } = string.Empty; - - public string ResetPasswordPolicy { get; set; } = string.Empty; -} diff --git a/src/clients/shared/CodeBreaker.Services/nuget.config b/src/clients/shared/CodeBreaker.Services/nuget.config deleted file mode 100644 index ac51e3b2..00000000 --- a/src/clients/shared/CodeBreaker.Services/nuget.config +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/src/services/shared/CodeBreaker.Data.Cosmos/CodeBreaker.Data.Cosmos.csproj b/src/services/shared/CodeBreaker.Data.Cosmos/CodeBreaker.Data.Cosmos.csproj deleted file mode 100644 index 22dc51b7..00000000 --- a/src/services/shared/CodeBreaker.Data.Cosmos/CodeBreaker.Data.Cosmos.csproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - net6.0;net7.0 - enable - enable - - - - CNInnovation.Codebreaker.Data.Cosmos - - EF Core data context to be used with Azure Cosmos DB - - - - - - - - - diff --git a/src/services/shared/CodeBreaker.Data.Cosmos/CodeBreakerContext.cs b/src/services/shared/CodeBreaker.Data.Cosmos/CodeBreakerContext.cs deleted file mode 100644 index 5c3c6451..00000000 --- a/src/services/shared/CodeBreaker.Data.Cosmos/CodeBreakerContext.cs +++ /dev/null @@ -1,75 +0,0 @@ -using CodeBreaker.Data.DbConfiguration; -using CodeBreaker.Shared.Exceptions; -using CodeBreaker.Shared.Models.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Logging; - -namespace CodeBreaker.Data; - -public class CodeBreakerContext : DbContext, ICodeBreakerRepository -{ - private readonly ILogger _logger; - - public CodeBreakerContext(DbContextOptions options, ILogger logger) : base(options) - { - _logger = logger; - } - - protected override void OnModelCreating(ModelBuilder modelBuilder) - { - modelBuilder.HasDefaultContainer("GameContainer"); - modelBuilder.ApplyConfigurationsFromAssembly(typeof(GameDbConfiguration).Assembly); - } - - public DbSet Games => Set(); - - public async Task CreateGameAsync(Game game) - { - Games.Add(game); - await SaveChangesAsync(); - _logger.LogInformation("Created game with id {gameId}", game.GameId); - } - - public async Task UpdateGameAsync(Game game) - { - Games.Update(game); - await SaveChangesAsync(); - _logger.LogInformation("Updated game with id {gameId}", game.GameId); - } - - public async Task DeleteGameAsync(Guid gameId) - { - Game game = await GetGameAsync(gameId, false) ?? throw new GameNotFoundException($"Game with id {gameId} not found"); - Games.Remove(game); - await SaveChangesAsync(); - } - - public async Task CancelGameAsync(Guid gameId) - { - Game game = await GetGameAsync(gameId, true) ?? throw new GameNotFoundException($"Game with id {gameId} not found"); - game.End = DateTime.Now; - await SaveChangesAsync(); - } - - public Task GetGameAsync(Guid gameId, bool withTracking = true) => - Games - .AsTracking(withTracking ? QueryTrackingBehavior.TrackAll : QueryTrackingBehavior.NoTracking) - .WithPartitionKey(gameId.ToString()) - .SingleOrDefaultAsync(g => g.GameId == gameId); - - public IAsyncEnumerable GetGamesByDateAsync(DateTime date) => - GetGamesByDateAsync(DateOnly.FromDateTime(date)); - - public IAsyncEnumerable GetGamesByDateAsync(DateOnly date) - { - DateTime begin = new (date.Year, date.Month, date.Day); - DateTime end = begin.AddDays(1); - - return Games - .AsNoTracking() - .Where(x => x.Start >= begin && x.Start < end) - .OrderByDescending(x => x.Start) - .Take(100) - .AsAsyncEnumerable(); - } -} diff --git a/src/services/shared/CodeBreaker.Data.Cosmos/DbConfiguration/GameDbConfiguration.cs b/src/services/shared/CodeBreaker.Data.Cosmos/DbConfiguration/GameDbConfiguration.cs deleted file mode 100644 index ea5e499f..00000000 --- a/src/services/shared/CodeBreaker.Data.Cosmos/DbConfiguration/GameDbConfiguration.cs +++ /dev/null @@ -1,14 +0,0 @@ -using CodeBreaker.Shared.Models.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -namespace CodeBreaker.Data.DbConfiguration; - -public class GameDbConfiguration : IEntityTypeConfiguration -{ - public void Configure(EntityTypeBuilder builder) - { - builder.HasKey(x => x.GameId); - builder.HasPartitionKey(x => x.GameId); - } -} diff --git a/src/services/shared/CodeBreaker.Data.Cosmos/ICodeBreakerRepository.cs b/src/services/shared/CodeBreaker.Data.Cosmos/ICodeBreakerRepository.cs deleted file mode 100644 index d00b1317..00000000 --- a/src/services/shared/CodeBreaker.Data.Cosmos/ICodeBreakerRepository.cs +++ /dev/null @@ -1,13 +0,0 @@ -using CodeBreaker.Shared.Models.Data; - -namespace CodeBreaker.Data; -public interface ICodeBreakerRepository -{ - Task CreateGameAsync(Game game); - Task DeleteGameAsync(Guid gameId); - Task CancelGameAsync(Guid gameId); - Task GetGameAsync(Guid gameId, bool withTracking = true); - IAsyncEnumerable GetGamesByDateAsync(DateOnly date); - IAsyncEnumerable GetGamesByDateAsync(DateTime date); - Task UpdateGameAsync(Game game); -} diff --git a/src/services/shared/CodeBreaker.Data.Cosmos/nuget.config b/src/services/shared/CodeBreaker.Data.Cosmos/nuget.config deleted file mode 100644 index ac51e3b2..00000000 --- a/src/services/shared/CodeBreaker.Data.Cosmos/nuget.config +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/src/shared/CodeBreaker.Shared/CodeBreaker.Shared.csproj b/src/shared/CodeBreaker.Shared/CodeBreaker.Shared.csproj deleted file mode 100644 index 0c5ae426..00000000 --- a/src/shared/CodeBreaker.Shared/CodeBreaker.Shared.csproj +++ /dev/null @@ -1,26 +0,0 @@ - - - - net7.0;net6.0 - enable - enable - Debug;Release - - - - CNInnovation.Codebreaker.Shared - - Contains Codebreaker model types used by applications on the client and the server - - - - - - - - - - - - - diff --git a/src/shared/CodeBreaker.Shared/Exceptions/EventBatchSizeException.cs b/src/shared/CodeBreaker.Shared/Exceptions/EventBatchSizeException.cs deleted file mode 100644 index 9f0b6fb2..00000000 --- a/src/shared/CodeBreaker.Shared/Exceptions/EventBatchSizeException.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System.Runtime.Serialization; - -namespace CodeBreaker.Shared.Exceptions; - -public class EventBatchSizeException : Exception -{ - public EventBatchSizeException() - { - } - - public EventBatchSizeException(string? message) : base(message) - { - } - - public EventBatchSizeException(string? message, Exception? innerException) : base(message, innerException) - { - } - - protected EventBatchSizeException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } -} diff --git a/src/shared/CodeBreaker.Shared/Exceptions/GameException.cs b/src/shared/CodeBreaker.Shared/Exceptions/GameException.cs deleted file mode 100644 index 8ebdf8b7..00000000 --- a/src/shared/CodeBreaker.Shared/Exceptions/GameException.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace CodeBreaker.Shared.Exceptions; - - -[Serializable] -public class GameException : Exception -{ - public GameException() { } - public GameException(string message) : base(message) { } - public GameException(string message, Exception inner) : base(message, inner) { } - protected GameException( - System.Runtime.Serialization.SerializationInfo info, - System.Runtime.Serialization.StreamingContext context) : base(info, context) { } -} diff --git a/src/shared/CodeBreaker.Shared/Exceptions/GameNotFoundException.cs b/src/shared/CodeBreaker.Shared/Exceptions/GameNotFoundException.cs deleted file mode 100644 index f177ac01..00000000 --- a/src/shared/CodeBreaker.Shared/Exceptions/GameNotFoundException.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace CodeBreaker.Shared.Exceptions; - -public class GameNotFoundException : NotFoundException -{ - public GameNotFoundException() - { - } - - public GameNotFoundException(string? message) : base(message) - { - } - - public GameNotFoundException(string? message, Exception? innerException) : base(message, innerException) - { - } -} diff --git a/src/shared/CodeBreaker.Shared/Exceptions/GameTypeNotFoundException.cs b/src/shared/CodeBreaker.Shared/Exceptions/GameTypeNotFoundException.cs deleted file mode 100644 index e056918c..00000000 --- a/src/shared/CodeBreaker.Shared/Exceptions/GameTypeNotFoundException.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace CodeBreaker.Shared.Exceptions; - -public class GameTypeNotFoundException : NotFoundException -{ - public GameTypeNotFoundException() - { - } - - public GameTypeNotFoundException(string? message) : base(message) - { - } - - public GameTypeNotFoundException(string? message, Exception? innerException) : base(message, innerException) - { - } -} diff --git a/src/shared/CodeBreaker.Shared/Exceptions/NotFoundException.cs b/src/shared/CodeBreaker.Shared/Exceptions/NotFoundException.cs deleted file mode 100644 index 15a7f0e9..00000000 --- a/src/shared/CodeBreaker.Shared/Exceptions/NotFoundException.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace CodeBreaker.Shared.Exceptions; - -public class NotFoundException : ApplicationException -{ - public NotFoundException() - { - } - - public NotFoundException(string? message) : base(message) - { - } - - public NotFoundException(string? message, Exception? innerException) : base(message, innerException) - { - } -} diff --git a/src/shared/CodeBreaker.Shared/Extensions/ConfigExtensions.cs b/src/shared/CodeBreaker.Shared/Extensions/ConfigExtensions.cs deleted file mode 100644 index 57c09ca3..00000000 --- a/src/shared/CodeBreaker.Shared/Extensions/ConfigExtensions.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Microsoft.Extensions.Configuration; - -public static class ConfigExtensions -{ - public static string GetRequired(this IConfiguration config, string configKey) => - config[configKey] ?? throw new InvalidOperationException($"Could not find configuration with key: \"{configKey}\""); -} diff --git a/src/shared/CodeBreaker.Shared/Models/Api/GameDtos.cs b/src/shared/CodeBreaker.Shared/Models/Api/GameDtos.cs deleted file mode 100644 index 3e47dc17..00000000 --- a/src/shared/CodeBreaker.Shared/Models/Api/GameDtos.cs +++ /dev/null @@ -1,24 +0,0 @@ -using CodeBreaker.Shared.Models.Data; - -namespace CodeBreaker.Shared.Models.Api; - -public readonly record struct GameDto( - Guid GameId, - IReadOnlyList Code, - GameType Type, - string Username, - DateTime Start, - DateTime? End, - IEnumerable> Moves -); - -public readonly record struct GetGamesResponse(IEnumerable Games); - -public readonly record struct GetGameResponse(GameDto Game); - -public readonly record struct CreateGameResponse(GameDto Game); - -public readonly record struct CreateGameRequest( - string Username, - string GameType -); diff --git a/src/shared/CodeBreaker.Shared/Models/Api/GameTypeDtos.cs b/src/shared/CodeBreaker.Shared/Models/Api/GameTypeDtos.cs deleted file mode 100644 index 247d65e4..00000000 --- a/src/shared/CodeBreaker.Shared/Models/Api/GameTypeDtos.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace CodeBreaker.Shared.Models.Api; - -public readonly record struct GameTypeDto(string Name); - -public readonly record struct GetGameTypesResponse( - IEnumerable GameTypes -); diff --git a/src/shared/CodeBreaker.Shared/Models/Api/MoveDtos.cs b/src/shared/CodeBreaker.Shared/Models/Api/MoveDtos.cs deleted file mode 100644 index d25b27f9..00000000 --- a/src/shared/CodeBreaker.Shared/Models/Api/MoveDtos.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace CodeBreaker.Shared.Models.Api; - -public readonly record struct MoveDto( - int MoveNumber, - IReadOnlyList GuessPegs, - KeyPegsDto? KeyPegs -); - -public readonly record struct CreateMoveResponse( - KeyPegsDto KeyPegs, - bool Ended, - bool Won -); - -public readonly record struct CreateMoveRequest(IReadOnlyList GuessPegs); - -public readonly record struct KeyPegsDto( - int Black, - int White -); diff --git a/src/shared/CodeBreaker.Shared/Models/Data/Colors.cs b/src/shared/CodeBreaker.Shared/Models/Data/Colors.cs deleted file mode 100644 index 6f43142e..00000000 --- a/src/shared/CodeBreaker.Shared/Models/Data/Colors.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace CodeBreaker.Shared.Models.Data; - -public static class Colors -{ - public const string Black = nameof(Black); - public const string White = nameof(White); - public const string Red = nameof(Red); - public const string Green = nameof(Green); - public const string Blue = nameof(Blue); - public const string Yellow = nameof(Yellow); - public const string Violet = nameof(Violet); - public const string LightBlue = nameof(LightBlue); - - public const string Rectangle = nameof(Rectangle); - public const string Circle = nameof(Circle); - public const string Ellipse = nameof(Ellipse); - public const string Triangle = nameof(Triangle); -} \ No newline at end of file diff --git a/src/shared/CodeBreaker.Shared/Models/Data/Game.cs b/src/shared/CodeBreaker.Shared/Models/Data/Game.cs deleted file mode 100644 index 9d1d7042..00000000 --- a/src/shared/CodeBreaker.Shared/Models/Data/Game.cs +++ /dev/null @@ -1,97 +0,0 @@ -namespace CodeBreaker.Shared.Models.Data; - -public class Game -{ - private readonly Guid _id; - - private readonly string _name = string.Empty; - - private readonly DateTime _start = DateTime.Now; - - private DateTime? _end; - - public Game() - { - } - - public Game(Guid gameId, GameType type, string username, IReadOnlyList code) - { - GameId = gameId; - Type = type; - Username = username; - Code = new List(code); - } - - public Game(Guid gameId, GameType type, string username, IReadOnlyList code, DateTime start, DateTime? end, IList moves) - : this(gameId, type, username, code) - { - Start = start; - End = end; - Moves = moves; - } - - /// - /// The Id of the game. - /// Used as partitionKey and primaryKey in Cosmos. - /// - public Guid GameId - { - get => _id; - init - { - if (value == default) - throw new ArgumentException(nameof(GameId)); - - _id = value; - } - } - - public GameType Type { get; init; } = GameType.Default; - - public string Username - { - get => _name; - init - { - if (string.IsNullOrWhiteSpace(value)) - throw new ArgumentException(nameof(Username)); - - _name = value; - } - } - - public IReadOnlyList Code { get; init; } = new List(); - - public DateTime Start - { - get => _start; - init - { - if (value == default) - throw new ArgumentException(nameof(Start)); - - _start = value; - } - } - - public DateTime? End - { - get => _end; - set - { - if (value < Start) - throw new ArgumentOutOfRangeException(nameof(End)); - - _end = value; - } - } - - public bool Ended => End != null; - - public bool Won => Moves.LastOrDefault()?.KeyPegs?.Black == Type.Holes; - - public IList Moves { get; init; } = new List(); - - public override string ToString() => - $"{GameId} for {Username}, {string.Join("..", Code)}"; -} diff --git a/src/shared/CodeBreaker.Shared/Models/Data/GameType.cs b/src/shared/CodeBreaker.Shared/Models/Data/GameType.cs deleted file mode 100644 index f4d75278..00000000 --- a/src/shared/CodeBreaker.Shared/Models/Data/GameType.cs +++ /dev/null @@ -1,75 +0,0 @@ -using static CodeBreaker.Shared.Models.Data.Colors; - -namespace CodeBreaker.Shared.Models.Data; - -public class GameType : GameType -{ - public GameType(string name, IReadOnlyList fields, int holes, int maxMoves) : base(name, fields, holes, maxMoves) - { - } - - public static GameType Default => - new ( - "6x4Game", - new string[] { Black, White, Red, Green, Blue, Yellow }, - 4, - 12 - ); -} - -public class GameType -{ - private readonly string _name = string.Empty; - - private readonly int _holes = 0; - - private readonly int _maxMoves = 0; - - public GameType(string name, IReadOnlyList fields, int holes, int maxMoves) - { - Name = name; - Fields = fields; - Holes = holes; - MaxMoves = maxMoves; - } - - public string Name - { - get => _name; - init - { - if (string.IsNullOrWhiteSpace(value)) - throw new ArgumentException(nameof(Name)); - - _name = value; - } - } - - public IReadOnlyList Fields { get; init; } = new List(); - - public int Holes - { - get => _holes; - init - { - if (value < 0) - throw new ArgumentOutOfRangeException(nameof(Holes)); - - _holes = value; - } - } - - public int MaxMoves - { - get => _maxMoves; - init - { - if (value < 0) - throw new ArgumentOutOfRangeException(nameof(MaxMoves)); - - _maxMoves = value; - } - } - - public override string ToString() => Name; -} diff --git a/src/shared/CodeBreaker.Shared/Models/Data/Move.cs b/src/shared/CodeBreaker.Shared/Models/Data/Move.cs deleted file mode 100644 index fc6e998a..00000000 --- a/src/shared/CodeBreaker.Shared/Models/Data/Move.cs +++ /dev/null @@ -1,116 +0,0 @@ -using System.Runtime.Serialization; - -namespace CodeBreaker.Shared.Models.Data; - -public class Move : Move -{ - public Move() - { - } - - public Move(IReadOnlyList guessPegs) - { - GuessPegs = guessPegs; - } - - public Move(int moveNumber, IReadOnlyList guessPegs) - : this(guessPegs) - { - MoveNumber = moveNumber; - } - - public Move(int moveNumber, IReadOnlyList guessPegs, KeyPegs? keyPegs) - : this(moveNumber, guessPegs) - { - KeyPegs = keyPegs; - } -} - -public class Move -{ - private int _moveNumber; - - public Move() - { - } - - public Move(IReadOnlyList guessPegs) - { - GuessPegs = guessPegs; - } - - public Move(int moveNumber, IReadOnlyList guessPegs) - : this(guessPegs) - { - MoveNumber = moveNumber; - } - - public Move(int moveNumber, IReadOnlyList guessPegs, KeyPegs? keyPegs) - : this(moveNumber, guessPegs) - { - KeyPegs = keyPegs; - } - - public int MoveNumber - { - get => _moveNumber; - set - { - if (value < 0) - throw new ArgumentOutOfRangeException(nameof(MoveNumber)); - - _moveNumber = value; - } - } - - public IReadOnlyList GuessPegs { get; init; } = new List(); - - public KeyPegs? KeyPegs { get; set; } - - public override string ToString() => - $"{MoveNumber}, {string.Join("..", GuessPegs)}"; -} - -public record struct KeyPegs -{ - private int _black = 0; - - private int _white = 0; - - public KeyPegs() - { - } - - public KeyPegs(int black, int white) - { - Black = black; - White = white; - } - - public int Black - { - get => _black; - set - { - if (value < 0) - throw new ArgumentOutOfRangeException(nameof(Black)); - - _black = value; - } - } - - public int White - { - get => _white; - set - { - if (value < 0) - throw new ArgumentOutOfRangeException(nameof(White)); - - _white = value; - } - } - - [IgnoreDataMember] - public int Total => Black + White; -} diff --git a/src/shared/CodeBreaker.Shared/Models/Data/Types.cs b/src/shared/CodeBreaker.Shared/Models/Data/Types.cs deleted file mode 100644 index 3b9e723e..00000000 --- a/src/shared/CodeBreaker.Shared/Models/Data/Types.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace CodeBreaker.Shared.Models.Data; - -public static class GameTypes -{ - public const string Game6x4 = nameof(Game6x4); - public const string Game6x4Mini = nameof(Game6x4Mini); - public const string Game8x5 = nameof(Game8x5); -} \ No newline at end of file diff --git a/src/shared/CodeBreaker.Shared/Models/Extensions/DtoExtensions.cs b/src/shared/CodeBreaker.Shared/Models/Extensions/DtoExtensions.cs deleted file mode 100644 index 3eb4a036..00000000 --- a/src/shared/CodeBreaker.Shared/Models/Extensions/DtoExtensions.cs +++ /dev/null @@ -1,61 +0,0 @@ -using CodeBreaker.Shared.Models.Api; -using CodeBreaker.Shared.Models.Data; - -namespace CodeBreaker.Shared.Models.Extensions; - -public static class DtoExtensions -{ - public static GameDto ToDto(this Game game) => - new() - { - GameId = game.GameId, - Type = game.Type, - Code = game.Code, - Username = game.Username, - Start = game.Start, - End = game.End, - Moves = game.Moves.Select(m => m.ToDto()) - }; - - public static MoveDto ToDto(this Move move) => - new() - { - MoveNumber = move.MoveNumber, - GuessPegs = move.GuessPegs, - KeyPegs = move.KeyPegs?.ToDto() - }; - - public static KeyPegsDto ToDto(this KeyPegs keyPegs) => - new() - { - Black = keyPegs.Black, - White = keyPegs.White - }; - - public static KeyPegs ToModel(this KeyPegsDto dto) => - new(dto.Black, dto.White); - - public static Game ToModel(this GameDto dto) => - new( - dto.GameId, - dto.Type, - dto.Username, - dto.Code, - dto.Start, - dto.End, - dto.Moves.Select(m => m.ToModel()).ToList() - ); - - public static Move ToModel(this MoveDto dto) => - new( - dto.MoveNumber, - dto.GuessPegs, - dto.KeyPegs?.ToModel() - ); - - public static GameTypeDto ToDto(this GameType gameType) => - new() - { - Name = gameType.Name - }; -} diff --git a/src/shared/CodeBreaker.Shared/Models/Extensions/GameExtensions.cs b/src/shared/CodeBreaker.Shared/Models/Extensions/GameExtensions.cs deleted file mode 100644 index 2e60e0b5..00000000 --- a/src/shared/CodeBreaker.Shared/Models/Extensions/GameExtensions.cs +++ /dev/null @@ -1,13 +0,0 @@ -using CodeBreaker.Shared.Models.Data; - -namespace CodeBreaker.Shared.Models.Extensions -{ - public static class GameExtensions - { - public static Move? GetLastMoveOrDefault(this Game game) => - game.Moves.OrderByDescending(x => x.MoveNumber).FirstOrDefault(); - - public static KeyPegs? GetLastKeyPegsOrDefault(this Game game) => - game.GetLastMoveOrDefault()?.KeyPegs; - } -} diff --git a/src/shared/CodeBreaker.Shared/Models/Live/EventPayloads/GameCreatedPayload.cs b/src/shared/CodeBreaker.Shared/Models/Live/EventPayloads/GameCreatedPayload.cs deleted file mode 100644 index a218a7fe..00000000 --- a/src/shared/CodeBreaker.Shared/Models/Live/EventPayloads/GameCreatedPayload.cs +++ /dev/null @@ -1,5 +0,0 @@ -using CodeBreaker.Shared.Models.Data; - -namespace CodeBreaker.Shared.Models.Live.EventPayloads; - -public record class GameCreatedPayload(Game Game); diff --git a/src/shared/CodeBreaker.Shared/Models/Live/EventPayloads/MoveCreatedPayload.cs b/src/shared/CodeBreaker.Shared/Models/Live/EventPayloads/MoveCreatedPayload.cs deleted file mode 100644 index c0941b0a..00000000 --- a/src/shared/CodeBreaker.Shared/Models/Live/EventPayloads/MoveCreatedPayload.cs +++ /dev/null @@ -1,5 +0,0 @@ -using CodeBreaker.Shared.Models.Data; - -namespace CodeBreaker.Shared.Models.Live.EventPayloads; - -public record class MoveCreatedPayload(Guid GameId, Move Move); diff --git a/src/shared/CodeBreaker.Shared/Models/Live/LiveEventNames.cs b/src/shared/CodeBreaker.Shared/Models/Live/LiveEventNames.cs deleted file mode 100644 index 59c585b9..00000000 --- a/src/shared/CodeBreaker.Shared/Models/Live/LiveEventNames.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace CodeBreaker.Shared.Models.Live; - -public static class LiveEventNames -{ - public const string GameCreatedEventName = "gameCreated"; - public const string GameCancelledEventName = "gameCancelled"; - public const string GameDeletedEventName = "gameDeleted"; - public const string GameFinishedEventName = "gameFinished"; - public const string MoveCreatedEventName = "moveCreated"; -} diff --git a/src/shared/CodeBreaker.Shared/Models/Live/LiveHubArgs.cs b/src/shared/CodeBreaker.Shared/Models/Live/LiveHubArgs.cs deleted file mode 100644 index 366375cc..00000000 --- a/src/shared/CodeBreaker.Shared/Models/Live/LiveHubArgs.cs +++ /dev/null @@ -1,26 +0,0 @@ -namespace CodeBreaker.Shared.Models.Live; - -public record LiveHubArgs -{ - private readonly string _name = string.Empty; - - private readonly object _data = new(); - - public LiveHubArgs(string name, object data) - { - Name = name; - Data = data; - } - - public string Name - { - get => _name; - init => _name = value ?? throw new ArgumentNullException(nameof(Name)); - } - - public object Data - { - get => _data; - init => _data = value ?? throw new ArgumentNullException(nameof(Data)); - } -} diff --git a/src/shared/CodeBreaker.Shared/Models/Report/ReportModels.cs b/src/shared/CodeBreaker.Shared/Models/Report/ReportModels.cs deleted file mode 100644 index 002d03b6..00000000 --- a/src/shared/CodeBreaker.Shared/Models/Report/ReportModels.cs +++ /dev/null @@ -1,10 +0,0 @@ -using CodeBreaker.Shared.Models.Data; - -namespace CodeBreaker.Shared.Models.Report; - -public record GamesInformationDetail(DateTime Date) -{ - public List Games { get; init; } = new List(); -} - -public record GamesInfo(DateTime Time, string User, int NumberMoves, Guid Id); diff --git a/src/shared/CodeBreaker.Shared/Models/Users/Api/GamerNameDtos.cs b/src/shared/CodeBreaker.Shared/Models/Users/Api/GamerNameDtos.cs deleted file mode 100644 index bf0f2cf6..00000000 --- a/src/shared/CodeBreaker.Shared/Models/Users/Api/GamerNameDtos.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace CodeBreaker.Shared.Models.Users.Api; - -public record class GamerNameValidityResponse(bool Valid); - -public record class GamerNameSuggestionsResponse(IAsyncEnumerable Suggestions); diff --git a/src/shared/CodeBreaker.Shared/Models/Users/GamerNameParts.cs b/src/shared/CodeBreaker.Shared/Models/Users/GamerNameParts.cs deleted file mode 100644 index 4cd43362..00000000 --- a/src/shared/CodeBreaker.Shared/Models/Users/GamerNameParts.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace CodeBreaker.Shared.Models.Users; - -public class GamerNameParts -{ - public string[] First { get; set; } = Array.Empty(); - - public string[] Second { get; set; } = Array.Empty(); -} diff --git a/src/shared/CodeBreaker.Shared/Models/Users/User.cs b/src/shared/CodeBreaker.Shared/Models/Users/User.cs deleted file mode 100644 index 03d6e5c0..00000000 --- a/src/shared/CodeBreaker.Shared/Models/Users/User.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace CodeBreaker.Shared.Models.Users; - -public class User -{ - public string Email { get; set; } = string.Empty; - - public string DisplayName { get; set; } = string.Empty; - - public string GivenName { get; set; } = string.Empty; - - public string Surname { get; set; } = string.Empty; - - public string GamerName { get; set; } = string.Empty; -} diff --git a/src/shared/CodeBreaker.Shared/Resources/Validators/Users/UserValidator.de.resx b/src/shared/CodeBreaker.Shared/Resources/Validators/Users/UserValidator.de.resx deleted file mode 100644 index e0f8cb84..00000000 --- a/src/shared/CodeBreaker.Shared/Resources/Validators/Users/UserValidator.de.resx +++ /dev/null @@ -1,132 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - E-Mailadresse - - - Spielername - - - Vorname - - - Nachname - - \ No newline at end of file diff --git a/src/shared/CodeBreaker.Shared/Resources/Validators/Users/UserValidator.en.resx b/src/shared/CodeBreaker.Shared/Resources/Validators/Users/UserValidator.en.resx deleted file mode 100644 index 0c9ada73..00000000 --- a/src/shared/CodeBreaker.Shared/Resources/Validators/Users/UserValidator.en.resx +++ /dev/null @@ -1,132 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - email address - - - gamer name - - - given name - - - surname - - \ No newline at end of file diff --git a/src/shared/CodeBreaker.Shared/Validators/Users/GamerNameValidator.cs b/src/shared/CodeBreaker.Shared/Validators/Users/GamerNameValidator.cs deleted file mode 100644 index eedaae3e..00000000 --- a/src/shared/CodeBreaker.Shared/Validators/Users/GamerNameValidator.cs +++ /dev/null @@ -1,15 +0,0 @@ -using FluentValidation; - -namespace CodeBreaker.Shared.Validators.Users; - -public class GamerNameValidator : AbstractValidator -{ - public GamerNameValidator(string name = "GamerName") - { - RuleFor(_ => _) - .NotEmpty() - .MinimumLength(3) - .MaximumLength(50) - .WithName(name); - } -} diff --git a/src/shared/CodeBreaker.Shared/Validators/Users/UserValidator.cs b/src/shared/CodeBreaker.Shared/Validators/Users/UserValidator.cs deleted file mode 100644 index 20cb1b15..00000000 --- a/src/shared/CodeBreaker.Shared/Validators/Users/UserValidator.cs +++ /dev/null @@ -1,26 +0,0 @@ -using CodeBreaker.Shared.Models.Users; -using FluentValidation; -using Microsoft.Extensions.Localization; - -namespace CodeBreaker.Shared.Validators.Users; - -public class UserValidator : AbstractValidator -{ - public UserValidator(IStringLocalizer localizer) - { - RuleFor(_ => _.Email) - .EmailAddress() - .MaximumLength(100) - .WithName(localizer["Email"]); - RuleFor(_ => _.GivenName) - .MinimumLength(2) - .MaximumLength(50) - .WithName(localizer["GivenName"]); - RuleFor(_ => _.Surname) - .MinimumLength(2) - .MaximumLength(50) - .WithName(localizer["Surname"]); - RuleFor(_ => _.GamerName) - .SetValidator(new GamerNameValidator(localizer["GamerName"])); - } -}