Fix build with docker

This commit is contained in:
CodeLiturgy 2022-08-13 06:34:20 +01:00
parent 53fb4acc67
commit 1da60db67c
51 changed files with 772 additions and 1324 deletions

View File

@ -4,6 +4,7 @@
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<LangVersion>10</LangVersion> <LangVersion>10</LangVersion>
<RootNamespace>BlueWest.WebApi</RootNamespace> <RootNamespace>BlueWest.WebApi</RootNamespace>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@ -16,8 +17,8 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\BlueWest.Data\BlueWest.Data.csproj" />
<ProjectReference Include="..\BlueWest\BlueWest.csproj" /> <ProjectReference Include="..\BlueWest\BlueWest.csproj" />
<Protobuf Include="Protos\greet.proto" />
</ItemGroup> </ItemGroup>

View File

@ -2,7 +2,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Linq; using System.Linq;
using BlueWest.Collections;
using BlueWest.Data; using BlueWest.Data;
using BlueWest.WebApi.MySQL; using BlueWest.WebApi.MySQL;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;

View File

@ -6,7 +6,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using BlueWest.Collections;
using BlueWest.Core; using BlueWest.Core;
using BlueWest.Tools; using BlueWest.Tools;
@ -15,7 +14,7 @@ namespace BlueWest.WebApi
public class Program public class Program
{ {
public static readonly EventManager EventManager = public static readonly EventManager EventManager =
new EventManager(new FastDictionary<Type, FastList<EventListenerBase>>(10000)); new EventManager(new Dictionary<Type, List<EventListenerBase>>(10000));
private static ThreadServer _threadServer; private static ThreadServer _threadServer;

View File

@ -1,13 +0,0 @@
syntax = "proto3";
service Greeter {
rpc SayHello (HelloRequest) returns (HelloReply);
}
message HelloRequest {
string name = 1;
}
message HelloReply {
string message = 1;
}

View File

@ -1,11 +0,0 @@
namespace BlueWest.WebApi.Service
{
public readonly struct CommandEvent
{
}
public class CommandService
{
}
}

View File

@ -1,11 +0,0 @@
using Microsoft.Extensions.Logging;
namespace BlueWest.WebApi.Service
{
public class GreeterService : Greeter.GreeterBase
{
public GreeterService(ILogger<GreeterService> logger)
{
}
}
}

View File

@ -11,12 +11,9 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using BlueWest.WebApi.MySQL; using BlueWest.WebApi.MySQL;
using BlueWest.WebApi.Service;
using BlueWest.WebApi.Tools; using BlueWest.WebApi.Tools;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace BlueWest.WebApi namespace BlueWest.WebApi
{ {
@ -34,13 +31,13 @@ namespace BlueWest.WebApi
{ {
services.AddCors(options => services.AddCors(options =>
{ {
options.AddPolicy(name: MyAllowSpecificOrigins, /*options.AddPolicy(name: MyAllowSpecificOrigins,
builder => builder =>
{ {
builder.WithOrigins("http://localhost", "http://127.0.0.1", "http://localhost:3000", builder.WithOrigins("http://localhost", "http://127.0.0.1", "http://localhost:3000",
"http://127.0.0.1:3000", "localhost:3000", "127.0.0.1:3000") "http://127.0.0.1:3000", "localhost:3000", "127.0.0.1:3000")
.AllowAnyHeader().AllowAnyMethod(); .AllowAnyHeader().AllowAnyMethod();
}); });*/
}); });
services.AddControllers(); services.AddControllers();
@ -67,7 +64,7 @@ namespace BlueWest.WebApi
services.AddGrpc(); // services.AddGrpc();
} }
@ -93,7 +90,7 @@ namespace BlueWest.WebApi
app.UseEndpoints(endpoints => app.UseEndpoints(endpoints =>
{ {
endpoints.MapControllers(); endpoints.MapControllers();
endpoints.MapGrpcService<GreeterService>(); // endpoints.MapGrpcService<GreeterService>();
}); });
} }

View File

@ -0,0 +1,589 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v6.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v6.0": {
"BlueWest.Api/1.0.0": {
"dependencies": {
"BlueWest": "1.0.0",
"BlueWest.Data": "1.0.0",
"Grpc.AspNetCore": "2.41.0",
"Grpc.AspNetCore.Server": "2.41.0",
"Grpc.AspNetCore.Web": "2.41.0",
"Pomelo.EntityFrameworkCore.MySql": "6.0.2",
"Swashbuckle.AspNetCore": "5.6.3",
"Swashbuckle.AspNetCore.Swagger": "6.2.3"
},
"runtime": {
"BlueWest.Api.dll": {}
}
},
"Google.Protobuf/3.18.0": {
"runtime": {
"lib/net5.0/Google.Protobuf.dll": {
"assemblyVersion": "3.18.0.0",
"fileVersion": "3.18.0.0"
}
}
},
"Grpc.AspNetCore/2.41.0": {
"dependencies": {
"Google.Protobuf": "3.18.0",
"Grpc.AspNetCore.Server.ClientFactory": "2.41.0",
"Grpc.Tools": "2.41.0"
}
},
"Grpc.AspNetCore.Server/2.41.0": {
"dependencies": {
"Grpc.Net.Common": "2.41.0"
},
"runtime": {
"lib/net6.0/Grpc.AspNetCore.Server.dll": {
"assemblyVersion": "2.0.0.0",
"fileVersion": "2.41.0.0"
}
}
},
"Grpc.AspNetCore.Server.ClientFactory/2.41.0": {
"dependencies": {
"Grpc.AspNetCore.Server": "2.41.0",
"Grpc.Net.ClientFactory": "2.41.0"
},
"runtime": {
"lib/net6.0/Grpc.AspNetCore.Server.ClientFactory.dll": {
"assemblyVersion": "2.0.0.0",
"fileVersion": "2.41.0.0"
}
}
},
"Grpc.AspNetCore.Web/2.41.0": {
"runtime": {
"lib/net6.0/Grpc.AspNetCore.Web.dll": {
"assemblyVersion": "2.0.0.0",
"fileVersion": "2.41.0.0"
}
}
},
"Grpc.Core.Api/2.41.0": {
"dependencies": {
"System.Memory": "4.5.3"
},
"runtime": {
"lib/netstandard2.0/Grpc.Core.Api.dll": {
"assemblyVersion": "2.0.0.0",
"fileVersion": "2.41.0.0"
}
}
},
"Grpc.Net.Client/2.41.0": {
"dependencies": {
"Grpc.Net.Common": "2.41.0",
"Microsoft.Extensions.Logging.Abstractions": "6.0.0"
},
"runtime": {
"lib/net6.0/Grpc.Net.Client.dll": {
"assemblyVersion": "2.0.0.0",
"fileVersion": "2.41.0.0"
}
}
},
"Grpc.Net.ClientFactory/2.41.0": {
"dependencies": {
"Grpc.Net.Client": "2.41.0",
"Microsoft.Extensions.Http": "3.0.3"
},
"runtime": {
"lib/net6.0/Grpc.Net.ClientFactory.dll": {
"assemblyVersion": "2.0.0.0",
"fileVersion": "2.41.0.0"
}
}
},
"Grpc.Net.Common/2.41.0": {
"dependencies": {
"Grpc.Core.Api": "2.41.0"
},
"runtime": {
"lib/net6.0/Grpc.Net.Common.dll": {
"assemblyVersion": "2.0.0.0",
"fileVersion": "2.41.0.0"
}
}
},
"Grpc.Tools/2.41.0": {},
"Microsoft.EntityFrameworkCore/6.0.7": {
"dependencies": {
"Microsoft.EntityFrameworkCore.Abstractions": "6.0.7",
"Microsoft.EntityFrameworkCore.Analyzers": "6.0.7",
"Microsoft.Extensions.Caching.Memory": "6.0.1",
"Microsoft.Extensions.DependencyInjection": "6.0.0",
"Microsoft.Extensions.Logging": "6.0.0",
"System.Collections.Immutable": "6.0.0",
"System.Diagnostics.DiagnosticSource": "6.0.0"
},
"runtime": {
"lib/net6.0/Microsoft.EntityFrameworkCore.dll": {
"assemblyVersion": "6.0.7.0",
"fileVersion": "6.0.722.31501"
}
}
},
"Microsoft.EntityFrameworkCore.Abstractions/6.0.7": {
"runtime": {
"lib/net6.0/Microsoft.EntityFrameworkCore.Abstractions.dll": {
"assemblyVersion": "6.0.7.0",
"fileVersion": "6.0.722.31501"
}
}
},
"Microsoft.EntityFrameworkCore.Analyzers/6.0.7": {},
"Microsoft.EntityFrameworkCore.Relational/6.0.7": {
"dependencies": {
"Microsoft.EntityFrameworkCore": "6.0.7",
"Microsoft.Extensions.Configuration.Abstractions": "6.0.0"
},
"runtime": {
"lib/net6.0/Microsoft.EntityFrameworkCore.Relational.dll": {
"assemblyVersion": "6.0.7.0",
"fileVersion": "6.0.722.31501"
}
}
},
"Microsoft.Extensions.ApiDescription.Server/3.0.0": {},
"Microsoft.Extensions.Caching.Abstractions/6.0.0": {
"dependencies": {
"Microsoft.Extensions.Primitives": "6.0.0"
}
},
"Microsoft.Extensions.Caching.Memory/6.0.1": {
"dependencies": {
"Microsoft.Extensions.Caching.Abstractions": "6.0.0",
"Microsoft.Extensions.DependencyInjection.Abstractions": "6.0.0",
"Microsoft.Extensions.Logging.Abstractions": "6.0.0",
"Microsoft.Extensions.Options": "6.0.0",
"Microsoft.Extensions.Primitives": "6.0.0"
},
"runtime": {
"lib/netstandard2.0/Microsoft.Extensions.Caching.Memory.dll": {
"assemblyVersion": "6.0.0.0",
"fileVersion": "6.0.222.6406"
}
}
},
"Microsoft.Extensions.Configuration.Abstractions/6.0.0": {
"dependencies": {
"Microsoft.Extensions.Primitives": "6.0.0"
}
},
"Microsoft.Extensions.DependencyInjection/6.0.0": {
"dependencies": {
"Microsoft.Extensions.DependencyInjection.Abstractions": "6.0.0",
"System.Runtime.CompilerServices.Unsafe": "6.0.0"
}
},
"Microsoft.Extensions.DependencyInjection.Abstractions/6.0.0": {},
"Microsoft.Extensions.Http/3.0.3": {
"dependencies": {
"Microsoft.Extensions.DependencyInjection.Abstractions": "6.0.0",
"Microsoft.Extensions.Logging": "6.0.0",
"Microsoft.Extensions.Options": "6.0.0"
}
},
"Microsoft.Extensions.Logging/6.0.0": {
"dependencies": {
"Microsoft.Extensions.DependencyInjection": "6.0.0",
"Microsoft.Extensions.DependencyInjection.Abstractions": "6.0.0",
"Microsoft.Extensions.Logging.Abstractions": "6.0.0",
"Microsoft.Extensions.Options": "6.0.0",
"System.Diagnostics.DiagnosticSource": "6.0.0"
}
},
"Microsoft.Extensions.Logging.Abstractions/6.0.0": {},
"Microsoft.Extensions.Options/6.0.0": {
"dependencies": {
"Microsoft.Extensions.DependencyInjection.Abstractions": "6.0.0",
"Microsoft.Extensions.Primitives": "6.0.0"
}
},
"Microsoft.Extensions.Primitives/6.0.0": {
"dependencies": {
"System.Runtime.CompilerServices.Unsafe": "6.0.0"
}
},
"Microsoft.OpenApi/1.2.3": {
"runtime": {
"lib/netstandard2.0/Microsoft.OpenApi.dll": {
"assemblyVersion": "1.2.3.0",
"fileVersion": "1.2.3.0"
}
}
},
"MySqlConnector/2.1.2": {
"runtime": {
"lib/net6.0/MySqlConnector.dll": {
"assemblyVersion": "2.0.0.0",
"fileVersion": "2.1.2.0"
}
}
},
"Pomelo.EntityFrameworkCore.MySql/6.0.2": {
"dependencies": {
"Microsoft.EntityFrameworkCore.Relational": "6.0.7",
"Microsoft.Extensions.DependencyInjection": "6.0.0",
"MySqlConnector": "2.1.2"
},
"runtime": {
"lib/net6.0/Pomelo.EntityFrameworkCore.MySql.dll": {
"assemblyVersion": "6.0.2.0",
"fileVersion": "6.0.2.0"
}
}
},
"Swashbuckle.AspNetCore/5.6.3": {
"dependencies": {
"Microsoft.Extensions.ApiDescription.Server": "3.0.0",
"Swashbuckle.AspNetCore.Swagger": "6.2.3",
"Swashbuckle.AspNetCore.SwaggerGen": "5.6.3",
"Swashbuckle.AspNetCore.SwaggerUI": "5.6.3"
}
},
"Swashbuckle.AspNetCore.Swagger/6.2.3": {
"dependencies": {
"Microsoft.OpenApi": "1.2.3"
},
"runtime": {
"lib/net6.0/Swashbuckle.AspNetCore.Swagger.dll": {
"assemblyVersion": "6.2.3.0",
"fileVersion": "6.2.3.0"
}
}
},
"Swashbuckle.AspNetCore.SwaggerGen/5.6.3": {
"dependencies": {
"Swashbuckle.AspNetCore.Swagger": "6.2.3"
},
"runtime": {
"lib/netcoreapp3.0/Swashbuckle.AspNetCore.SwaggerGen.dll": {
"assemblyVersion": "5.6.3.0",
"fileVersion": "5.6.3.0"
}
}
},
"Swashbuckle.AspNetCore.SwaggerUI/5.6.3": {
"runtime": {
"lib/netcoreapp3.0/Swashbuckle.AspNetCore.SwaggerUI.dll": {
"assemblyVersion": "5.6.3.0",
"fileVersion": "5.6.3.0"
}
}
},
"System.Collections.Immutable/6.0.0": {
"dependencies": {
"System.Runtime.CompilerServices.Unsafe": "6.0.0"
}
},
"System.Diagnostics.DiagnosticSource/6.0.0": {
"dependencies": {
"System.Runtime.CompilerServices.Unsafe": "6.0.0"
}
},
"System.Memory/4.5.3": {},
"System.Runtime.CompilerServices.Unsafe/6.0.0": {},
"BlueWest/1.0.0": {
"runtime": {
"BlueWest.dll": {}
}
},
"BlueWest.Data/1.0.0": {
"dependencies": {
"Math-Expression-Evaluator": "1.3.2"
},
"runtime": {
"BlueWest.Data.dll": {}
}
},
"Math-Expression-Evaluator/1.3.2": {
"runtime": {
"SimpleExpressionEvaluator.dll": {}
}
}
}
},
"libraries": {
"BlueWest.Api/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"Google.Protobuf/3.18.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-Jm6+nppUm9LD+XVsLFkf1YyVlAKsG5gq+Hc/Rn3Zi2pDObBI6PCH/eHBFUJdARl40DpczEdHlV3+WTPOGIXetg==",
"path": "google.protobuf/3.18.0",
"hashPath": "google.protobuf.3.18.0.nupkg.sha512"
},
"Grpc.AspNetCore/2.41.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-JMwlIpaI6QnuO/LaHu40Oiq1ssIJTi4Q9z+MsKDeL8rqp9HFBzhepYnoWxXZZiahgLaC2kVDlcxbYuzucImBgQ==",
"path": "grpc.aspnetcore/2.41.0",
"hashPath": "grpc.aspnetcore.2.41.0.nupkg.sha512"
},
"Grpc.AspNetCore.Server/2.41.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-Snbmre+4zd7w5SKmaAq49G6l3eXpKwn6d//ph2klloVEradOvvMd1q2bYybG4Ryr6YU6bN2zJRpUQjKZy1JZug==",
"path": "grpc.aspnetcore.server/2.41.0",
"hashPath": "grpc.aspnetcore.server.2.41.0.nupkg.sha512"
},
"Grpc.AspNetCore.Server.ClientFactory/2.41.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-no6+pmtH4PEqRyomEG0eQlPaO4hEY5bBDvEWfn6bVz1eRlE22L2+/XZay7AzIkrILsnm+GZIngEdnK8onfrJkQ==",
"path": "grpc.aspnetcore.server.clientfactory/2.41.0",
"hashPath": "grpc.aspnetcore.server.clientfactory.2.41.0.nupkg.sha512"
},
"Grpc.AspNetCore.Web/2.41.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-DdHsgKThh7Df7awF7j5QN3dmn0Ao/PG3A6IXqP/edmkEhGeYiMcWafwzxRLT0St2JJtFiGdvWHGWmQMpXU4mBA==",
"path": "grpc.aspnetcore.web/2.41.0",
"hashPath": "grpc.aspnetcore.web.2.41.0.nupkg.sha512"
},
"Grpc.Core.Api/2.41.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-bQ/mLaeACJ16hINQzKZA0ge648acF0OUiHd8JMdvpywJ41UFilDOd+t3yDG0M2XxgbB98z8EUf0HnprHLOO0qg==",
"path": "grpc.core.api/2.41.0",
"hashPath": "grpc.core.api.2.41.0.nupkg.sha512"
},
"Grpc.Net.Client/2.41.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-hKuRI7eHxIdrBtricxXuNu+vzjErt7n+zcIr47M56pnajKnzFlG4zwLiPCuxKC22cZTI5S6ef50jCrI/vQrL2w==",
"path": "grpc.net.client/2.41.0",
"hashPath": "grpc.net.client.2.41.0.nupkg.sha512"
},
"Grpc.Net.ClientFactory/2.41.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-8uUxz9Sbpz7dudq3i2hBfmaRbLHImFcGx1Kn9CtpGtBok3WXL7FepUj0SIU4Iv95VQNYbefi41mIGxFylAO6Mg==",
"path": "grpc.net.clientfactory/2.41.0",
"hashPath": "grpc.net.clientfactory.2.41.0.nupkg.sha512"
},
"Grpc.Net.Common/2.41.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-Mcb6ybFRZYEqn1UVpfCADL2HSTJSK9+V2BBLyS6vebMNkmGwqa0KQ3x++kC+n28MAP4BlrR+jxW0XGNP6V9amw==",
"path": "grpc.net.common/2.41.0",
"hashPath": "grpc.net.common.2.41.0.nupkg.sha512"
},
"Grpc.Tools/2.41.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-u5jiyjo/ZX9O3WlrxEcM5yrnA45G+CM3ukMhDGZnaeXChqCNJEZDpayBiEAdeD4FZ/pAaGDr4rn1SpaHxLtPrw==",
"path": "grpc.tools/2.41.0",
"hashPath": "grpc.tools.2.41.0.nupkg.sha512"
},
"Microsoft.EntityFrameworkCore/6.0.7": {
"type": "package",
"serviceable": true,
"sha512": "sha512-9BsvGSpTzxvqnxH19wLBFivK5TzWmsHZQc/1cQ4b2e+k85aIG9R4FYewQLHZdPrAxNQImXjTyW5nRI3s1rpt6A==",
"path": "microsoft.entityframeworkcore/6.0.7",
"hashPath": "microsoft.entityframeworkcore.6.0.7.nupkg.sha512"
},
"Microsoft.EntityFrameworkCore.Abstractions/6.0.7": {
"type": "package",
"serviceable": true,
"sha512": "sha512-bjU0CkTqldgpVPTSj9M+R/3EaTz+u0jMeQMIC91YdGYDbpX/tAN5UYx+Ihzk4AtP8gmhburQUgMTdnmCE9c5sA==",
"path": "microsoft.entityframeworkcore.abstractions/6.0.7",
"hashPath": "microsoft.entityframeworkcore.abstractions.6.0.7.nupkg.sha512"
},
"Microsoft.EntityFrameworkCore.Analyzers/6.0.7": {
"type": "package",
"serviceable": true,
"sha512": "sha512-VAOrGma8mRspUb/9quwIr21UZVqfWOcRQqhcYNkHBUD7woenwFTBvntiC9h2Ebtvj/BrRfezqjaHpWVvPSg4dw==",
"path": "microsoft.entityframeworkcore.analyzers/6.0.7",
"hashPath": "microsoft.entityframeworkcore.analyzers.6.0.7.nupkg.sha512"
},
"Microsoft.EntityFrameworkCore.Relational/6.0.7": {
"type": "package",
"serviceable": true,
"sha512": "sha512-0uo4fPDHutMbd9AJJEKl2q/2fYuFGA8tEBE2fQeQFaNDd+F/aUjaXc1FUD84J7Wcax8WP40rZo1E0u9A0yPPZw==",
"path": "microsoft.entityframeworkcore.relational/6.0.7",
"hashPath": "microsoft.entityframeworkcore.relational.6.0.7.nupkg.sha512"
},
"Microsoft.Extensions.ApiDescription.Server/3.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-LH4OE/76F6sOCslif7+Xh3fS/wUUrE5ryeXAMcoCnuwOQGT5Smw0p57IgDh/pHgHaGz/e+AmEQb7pRgb++wt0w==",
"path": "microsoft.extensions.apidescription.server/3.0.0",
"hashPath": "microsoft.extensions.apidescription.server.3.0.0.nupkg.sha512"
},
"Microsoft.Extensions.Caching.Abstractions/6.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-bcz5sSFJbganH0+YrfvIjJDIcKNW7TL07C4d1eTmXy/wOt52iz4LVogJb6pazs7W0+74j0YpXFErvp++Aq5Bsw==",
"path": "microsoft.extensions.caching.abstractions/6.0.0",
"hashPath": "microsoft.extensions.caching.abstractions.6.0.0.nupkg.sha512"
},
"Microsoft.Extensions.Caching.Memory/6.0.1": {
"type": "package",
"serviceable": true,
"sha512": "sha512-B4y+Cev05eMcjf1na0v9gza6GUtahXbtY1JCypIgx3B4Ea/KAgsWyXEmW4q6zMbmTMtKzmPVk09rvFJirvMwTg==",
"path": "microsoft.extensions.caching.memory/6.0.1",
"hashPath": "microsoft.extensions.caching.memory.6.0.1.nupkg.sha512"
},
"Microsoft.Extensions.Configuration.Abstractions/6.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-qWzV9o+ZRWq+pGm+1dF+R7qTgTYoXvbyowRoBxQJGfqTpqDun2eteerjRQhq5PQ/14S+lqto3Ft4gYaRyl4rdQ==",
"path": "microsoft.extensions.configuration.abstractions/6.0.0",
"hashPath": "microsoft.extensions.configuration.abstractions.6.0.0.nupkg.sha512"
},
"Microsoft.Extensions.DependencyInjection/6.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-k6PWQMuoBDGGHOQTtyois2u4AwyVcIwL2LaSLlTZQm2CYcJ1pxbt6jfAnpWmzENA/wfrYRI/X9DTLoUkE4AsLw==",
"path": "microsoft.extensions.dependencyinjection/6.0.0",
"hashPath": "microsoft.extensions.dependencyinjection.6.0.0.nupkg.sha512"
},
"Microsoft.Extensions.DependencyInjection.Abstractions/6.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-xlzi2IYREJH3/m6+lUrQlujzX8wDitm4QGnUu6kUXTQAWPuZY8i+ticFJbzfqaetLA6KR/rO6Ew/HuYD+bxifg==",
"path": "microsoft.extensions.dependencyinjection.abstractions/6.0.0",
"hashPath": "microsoft.extensions.dependencyinjection.abstractions.6.0.0.nupkg.sha512"
},
"Microsoft.Extensions.Http/3.0.3": {
"type": "package",
"serviceable": true,
"sha512": "sha512-dcyB8szIcSynjVZRuFgqkZpPgTc5zeRSj1HMXSmNqWbHYKiPYJl8ZQgBHz6wmZNSUUNGpCs5uxUg8DZHHDC1Ew==",
"path": "microsoft.extensions.http/3.0.3",
"hashPath": "microsoft.extensions.http.3.0.3.nupkg.sha512"
},
"Microsoft.Extensions.Logging/6.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-eIbyj40QDg1NDz0HBW0S5f3wrLVnKWnDJ/JtZ+yJDFnDj90VoPuoPmFkeaXrtu+0cKm5GRAwoDf+dBWXK0TUdg==",
"path": "microsoft.extensions.logging/6.0.0",
"hashPath": "microsoft.extensions.logging.6.0.0.nupkg.sha512"
},
"Microsoft.Extensions.Logging.Abstractions/6.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-/HggWBbTwy8TgebGSX5DBZ24ndhzi93sHUBDvP1IxbZD7FDokYzdAr6+vbWGjw2XAfR2EJ1sfKUotpjHnFWPxA==",
"path": "microsoft.extensions.logging.abstractions/6.0.0",
"hashPath": "microsoft.extensions.logging.abstractions.6.0.0.nupkg.sha512"
},
"Microsoft.Extensions.Options/6.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-dzXN0+V1AyjOe2xcJ86Qbo233KHuLEY0njf/P2Kw8SfJU+d45HNS2ctJdnEnrWbM9Ye2eFgaC5Mj9otRMU6IsQ==",
"path": "microsoft.extensions.options/6.0.0",
"hashPath": "microsoft.extensions.options.6.0.0.nupkg.sha512"
},
"Microsoft.Extensions.Primitives/6.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-9+PnzmQFfEFNR9J2aDTfJGGupShHjOuGw4VUv+JB044biSHrnmCIMD+mJHmb2H7YryrfBEXDurxQ47gJZdCKNQ==",
"path": "microsoft.extensions.primitives/6.0.0",
"hashPath": "microsoft.extensions.primitives.6.0.0.nupkg.sha512"
},
"Microsoft.OpenApi/1.2.3": {
"type": "package",
"serviceable": true,
"sha512": "sha512-Nug3rO+7Kl5/SBAadzSMAVgqDlfGjJZ0GenQrLywJ84XGKO0uRqkunz5Wyl0SDwcR71bAATXvSdbdzPrYRYKGw==",
"path": "microsoft.openapi/1.2.3",
"hashPath": "microsoft.openapi.1.2.3.nupkg.sha512"
},
"MySqlConnector/2.1.2": {
"type": "package",
"serviceable": true,
"sha512": "sha512-JVokQTUNN3WHAu9Vw8ieeq1dXTFokJiig5P0VJ4f439UxRrsPo6SaVWC8Zdm6mkPeQFhZ0/9afdWa02EY/1j/w==",
"path": "mysqlconnector/2.1.2",
"hashPath": "mysqlconnector.2.1.2.nupkg.sha512"
},
"Pomelo.EntityFrameworkCore.MySql/6.0.2": {
"type": "package",
"serviceable": true,
"sha512": "sha512-KvlZ800CnEuEGnxj5OT1fCKGjQXxW5kpPlCP91JqBYG+2Z3927eqXmlX6LLKUt4swqE8ZsEQ+Zkpab8bqstf4g==",
"path": "pomelo.entityframeworkcore.mysql/6.0.2",
"hashPath": "pomelo.entityframeworkcore.mysql.6.0.2.nupkg.sha512"
},
"Swashbuckle.AspNetCore/5.6.3": {
"type": "package",
"serviceable": true,
"sha512": "sha512-UkL9GU0mfaA+7RwYjEaBFvAzL8qNQhNqAeV5uaWUu/Z+fVgvK9FHkGCpTXBqSQeIHuZaIElzxnLDdIqGzuCnVg==",
"path": "swashbuckle.aspnetcore/5.6.3",
"hashPath": "swashbuckle.aspnetcore.5.6.3.nupkg.sha512"
},
"Swashbuckle.AspNetCore.Swagger/6.2.3": {
"type": "package",
"serviceable": true,
"sha512": "sha512-qOF7j1sL0bWm8g/qqHVPCvkO3JlVvUIB8WfC98kSh6BT5y5DAnBNctfac7XR5EZf+eD7/WasvANncTqwZYfmWQ==",
"path": "swashbuckle.aspnetcore.swagger/6.2.3",
"hashPath": "swashbuckle.aspnetcore.swagger.6.2.3.nupkg.sha512"
},
"Swashbuckle.AspNetCore.SwaggerGen/5.6.3": {
"type": "package",
"serviceable": true,
"sha512": "sha512-CkhVeod/iLd3ikVTDOwG5sym8BE5xbqGJ15iF3cC7ZPg2kEwDQL4a88xjkzsvC9oOB2ax6B0rK0EgRK+eOBX+w==",
"path": "swashbuckle.aspnetcore.swaggergen/5.6.3",
"hashPath": "swashbuckle.aspnetcore.swaggergen.5.6.3.nupkg.sha512"
},
"Swashbuckle.AspNetCore.SwaggerUI/5.6.3": {
"type": "package",
"serviceable": true,
"sha512": "sha512-BPvcPxQRMsYZ3HnYmGKRWDwX4Wo29WHh14Q6B10BB8Yfbbcza+agOC2UrBFA1EuaZuOsFLbp6E2+mqVNF/Je8A==",
"path": "swashbuckle.aspnetcore.swaggerui/5.6.3",
"hashPath": "swashbuckle.aspnetcore.swaggerui.5.6.3.nupkg.sha512"
},
"System.Collections.Immutable/6.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-l4zZJ1WU2hqpQQHXz1rvC3etVZN+2DLmQMO79FhOTZHMn8tDRr+WU287sbomD0BETlmKDn0ygUgVy9k5xkkJdA==",
"path": "system.collections.immutable/6.0.0",
"hashPath": "system.collections.immutable.6.0.0.nupkg.sha512"
},
"System.Diagnostics.DiagnosticSource/6.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-frQDfv0rl209cKm1lnwTgFPzNigy2EKk1BS3uAvHvlBVKe5cymGyHO+Sj+NLv5VF/AhHsqPIUUwya5oV4CHMUw==",
"path": "system.diagnostics.diagnosticsource/6.0.0",
"hashPath": "system.diagnostics.diagnosticsource.6.0.0.nupkg.sha512"
},
"System.Memory/4.5.3": {
"type": "package",
"serviceable": true,
"sha512": "sha512-3oDzvc/zzetpTKWMShs1AADwZjQ/36HnsufHRPcOjyRAAMLDlu2iD33MBI2opxnezcVUtXyqDXXjoFMOU9c7SA==",
"path": "system.memory/4.5.3",
"hashPath": "system.memory.4.5.3.nupkg.sha512"
},
"System.Runtime.CompilerServices.Unsafe/6.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-/iUeP3tq1S0XdNNoMz5C9twLSrM/TH+qElHkXWaPvuNOt+99G75NrV0OS2EqHx5wMN7popYjpc8oTjC1y16DLg==",
"path": "system.runtime.compilerservices.unsafe/6.0.0",
"hashPath": "system.runtime.compilerservices.unsafe.6.0.0.nupkg.sha512"
},
"BlueWest/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"BlueWest.Data/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"Math-Expression-Evaluator/1.3.2": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,36 @@
<?xml version="1.0"?>
<doc>
<assembly>
<name>SimpleExpressionEvaluator</name>
</assembly>
<members>
<member name="T:SimpleExpressionEvaluator.ExpressionEvaluator">
<summary>
Class for compiling and evaluating simple mathematical expressions
</summary>
</member>
<member name="P:SimpleExpressionEvaluator.ExpressionEvaluator._culture">
<summary>
Gets the current culture used by <see cref="T:SimpleExpressionEvaluator.ExpressionEvaluator"></see> when parsing strings into numbers
</summary>
</member>
<member name="M:SimpleExpressionEvaluator.ExpressionEvaluator.#ctor">
<summary>
Initializes new instance of <see cref="T:SimpleExpressionEvaluator.ExpressionEvaluator"></see> using <see cref="P:System.Globalization.CultureInfo.InvariantCulture" />
</summary>
</member>
<member name="M:SimpleExpressionEvaluator.ExpressionEvaluator.#ctor(System.Globalization.CultureInfo)">
<summary>
Initializes new instance of <see cref="T:SimpleExpressionEvaluator.ExpressionEvaluator"></see> using specified culture info
</summary>
<param name="culture">Culture to use for parsing decimal numbers</param>
</member>
<member name="M:SimpleExpressionEvaluator.ExpressionEvaluator.Compile(System.String)">
<summary>
Compiles parameterized mathematical expression into a delegate which can be invoked with different arguments without having to parse the expression again.
</summary>
<param name="expression">Expression to parse and compile</param>
<returns>Delegate compiled from the expression</returns>
</member>
</members>
</doc>

View File

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}

View File

@ -0,0 +1,13 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"LocalMySQL": "server=127.0.0.1;user=blueuser;password=JwuWxhWxhh$X1;database=bluedb;"
}
}

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\BlueWest.Api.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>

View File

@ -1,12 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MessagePack" Version="2.3.85" />
</ItemGroup>
</Project>

View File

@ -1,943 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;
namespace BlueWest.Collections
{
internal static class DictionaryHelper
{
/// <summary>
/// Minimum size we're willing to let hashtables be.
/// Must be a power of two, and at least 4.
/// Note, however, that for a given hashtable, the initial size is a function of the first constructor arg, and may be > kMinBuckets.
/// </summary>
internal const int kMinBuckets = 4;
/// <summary>
/// By default, if you don't specify a hashtable size at construction-time, we use this size. Must be a power of two, and at least kMinBuckets.
/// </summary>
internal const int kInitialCapacity = 32;
internal const int kPowerOfTableSize = 2048;
private readonly static int[] nextPowerOf2Table = new int[kPowerOfTableSize];
static DictionaryHelper()
{
for (int i = 0; i <= kMinBuckets; i++)
nextPowerOf2Table[i] = kMinBuckets;
for (int i = kMinBuckets + 1; i < kPowerOfTableSize; i++)
nextPowerOf2Table[i] = NextPowerOf2Internal(i);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static int NextPowerOf2(int v)
{
if (v < kPowerOfTableSize)
{
return nextPowerOf2Table[v];
}
else
{
return NextPowerOf2Internal(v);
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static int NextPowerOf2Internal(int v)
{
v--;
v |= v >> 1;
v |= v >> 2;
v |= v >> 4;
v |= v >> 8;
v |= v >> 16;
v++;
return v;
}
}
public class FastDictionary<TKey, TValue> : IEnumerable<KeyValuePair<TKey, TValue>>
{
const int InvalidNodePosition = -1;
public const uint kUnusedHash = 0xFFFFFFFF;
public const uint kDeletedHash = 0xFFFFFFFE;
// TLoadFactor4 - controls hash map load. 4 means 100% load, ie. hashmap will grow
// when number of items == capacity. Default value of 6 means it grows when
// number of items == capacity * 3/2 (6/4). Higher load == tighter maps, but bigger
// risk of collisions.
static int tLoadFactor = 6;
private struct Entry
{
public uint Hash;
public TKey Key;
public TValue Value;
public Entry ( uint hash, TKey key, TValue value)
{
this.Hash = hash;
this.Key = key;
this.Value = value;
}
}
private Entry[] _entries;
private int _capacity;
private int _initialCapacity; // This is the initial capacity of the dictionary, we will never shrink beyond this point.
private int _size; // This is the real counter of how many items are in the hash-table (regardless of buckets)
private int _numberOfUsed; // How many used buckets.
private int _numberOfDeleted; // how many occupied buckets are marked deleted
private int _nextGrowthThreshold;
private readonly IEqualityComparer<TKey> comparer;
public IEqualityComparer<TKey> Comparer
{
get { return comparer; }
}
public int Capacity
{
get { return _capacity; }
}
public int Count
{
get { return _size; }
}
public bool IsEmpty
{
get { return Count == 0; }
}
public FastDictionary(int initialBucketCount, IEnumerable<KeyValuePair<TKey, TValue>> src, IEqualityComparer<TKey> comparer)
: this(initialBucketCount, comparer)
{
Contract.Requires(src != null);
Contract.Ensures(_capacity >= initialBucketCount);
foreach (var item in src)
this[item.Key] = item.Value;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public FastDictionary(FastDictionary<TKey, TValue> src, IEqualityComparer<TKey> comparer)
: this(src._capacity, src, comparer)
{ }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public FastDictionary(FastDictionary<TKey, TValue> src)
: this(src._capacity, src, src.comparer)
{ }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public FastDictionary(int initialBucketCount, FastDictionary<TKey, TValue> src, IEqualityComparer<TKey> comparer)
{
Contract.Requires(src != null);
Contract.Ensures(_capacity >= initialBucketCount);
Contract.Ensures(_capacity >= src._capacity);
this.comparer = comparer ?? EqualityComparer<TKey>.Default;
this._initialCapacity = DictionaryHelper.NextPowerOf2(initialBucketCount);
this._capacity = Math.Max(src._capacity, initialBucketCount);
this._size = src._size;
this._numberOfUsed = src._numberOfUsed;
this._numberOfDeleted = src._numberOfDeleted;
this._nextGrowthThreshold = src._nextGrowthThreshold;
int newCapacity = _capacity;
if (comparer == src.comparer)
{
// Initialization through copy (very efficient) because the comparer is the same.
this._entries = new Entry[newCapacity];
Array.Copy(src._entries, _entries, newCapacity);
}
else
{
// Initialization through rehashing because the comparer is not the same.
var entries = new Entry[newCapacity];
BlockCopyMemoryHelper.Memset(entries, new Entry(kUnusedHash, default(TKey), default(TValue)));
// Creating a temporary alias to use for rehashing.
this._entries = src._entries;
// This call will rewrite the aliases
Rehash(entries);
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public FastDictionary(IEqualityComparer<TKey> comparer)
: this(DictionaryHelper.kInitialCapacity, comparer)
{ }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public FastDictionary(int initialBucketCount, IEqualityComparer<TKey> comparer)
{
Contract.Ensures(_capacity >= initialBucketCount);
this.comparer = comparer ?? EqualityComparer<TKey>.Default;
// Calculate the next power of 2.
int newCapacity = initialBucketCount >= DictionaryHelper.kMinBuckets ? initialBucketCount : DictionaryHelper.kMinBuckets;
newCapacity = DictionaryHelper.NextPowerOf2(newCapacity);
this._initialCapacity = newCapacity;
// Initialization
this._entries = new Entry[newCapacity];
BlockCopyMemoryHelper.Memset(this._entries, new Entry(kUnusedHash, default(TKey), default(TValue)));
this._capacity = newCapacity;
this._numberOfUsed = 0;
this._numberOfDeleted = 0;
this._size = 0;
this._nextGrowthThreshold = _capacity * 4 / tLoadFactor;
}
public FastDictionary(int initialBucketCount = DictionaryHelper.kInitialCapacity)
: this(initialBucketCount, EqualityComparer<TKey>.Default)
{ }
public void Add(TKey key, TValue value)
{
Contract.Ensures(this._numberOfUsed <= this._capacity);
Contract.EndContractBlock();
if (key == null)
throw new ArgumentNullException("key");
ResizeIfNeeded();
int hash = GetInternalHashCode(key);
int bucket = hash % _capacity;
uint uhash = (uint)hash;
int numProbes = 1;
do
{
uint nHash = _entries[bucket].Hash;
if (nHash == kUnusedHash)
{
_numberOfUsed++;
_size++;
goto SET;
}
if (nHash == uhash && comparer.Equals(_entries[bucket].Key, key))
throw new ArgumentException("Cannot add duplicated key.", "key");
bucket = (bucket + numProbes) % _capacity;
numProbes++;
}
while (true);
SET:
this._entries[bucket].Hash = uhash;
this._entries[bucket].Key = key;
this._entries[bucket].Value = value;
}
public bool Remove(TKey key)
{
Contract.Ensures(this._numberOfUsed < this._capacity);
if (key == null)
throw new ArgumentNullException("key");
int bucket = Lookup(key);
if (bucket == InvalidNodePosition)
return false;
SetDeleted(bucket);
return true;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void SetDeleted(int node)
{
Contract.Ensures(_size <= Contract.OldValue<int>(_size));
if (_entries[node].Hash < kDeletedHash)
{
_entries[node].Hash = kDeletedHash;
_entries[node].Key = default(TKey);
_entries[node].Value = default(TValue);
_numberOfDeleted++;
_size--;
}
Contract.Assert(_numberOfDeleted >= Contract.OldValue<int>(_numberOfDeleted));
Contract.Assert(_entries[node].Hash == kDeletedHash);
if (3 * this._numberOfDeleted / 2 > this._capacity - this._numberOfUsed)
{
// We will force a rehash with the growth factor based on the current size.
Shrink(Math.Max(_initialCapacity, _size * 2));
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void ResizeIfNeeded()
{
if (_size >= _nextGrowthThreshold)
{
Grow(_capacity * 2);
}
}
private void Shrink(int newCapacity)
{
Contract.Requires(newCapacity > _size);
Contract.Ensures(this._numberOfUsed < this._capacity);
// Calculate the next power of 2.
newCapacity = Math.Max(DictionaryHelper.NextPowerOf2(newCapacity), _initialCapacity);
var entries = new Entry[newCapacity];
BlockCopyMemoryHelper.Memset(entries, new Entry(kUnusedHash, default(TKey), default(TValue)));
Rehash(entries);
}
public TValue this[TKey key]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
Contract.Requires(key != null);
Contract.Ensures(this._numberOfUsed <= this._capacity);
int hash = GetInternalHashCode(key);
int bucket = hash % _capacity;
var entries = _entries;
uint nHash;
int numProbes = 1;
do
{
nHash = entries[bucket].Hash;
if (nHash == hash && comparer.Equals(entries[bucket].Key, key))
return entries[bucket].Value;
bucket = (bucket + numProbes) % _capacity;
numProbes++;
}
while (nHash != kUnusedHash);
throw new KeyNotFoundException();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
set
{
Contract.Requires(key != null);
Contract.Ensures(this._numberOfUsed <= this._capacity);
ResizeIfNeeded();
int hash = GetInternalHashCode(key);
int bucket = hash % _capacity;
uint uhash = (uint)hash;
int numProbes = 1;
do
{
uint nHash = _entries[bucket].Hash;
if (nHash == kUnusedHash)
{
_numberOfUsed++;
_size++;
goto SET;
}
if (nHash == uhash && comparer.Equals(_entries[bucket].Key, key))
goto SET;
bucket = (bucket + numProbes) % _capacity;
numProbes++;
}
while (true);
SET:
this._entries[bucket].Hash = uhash;
this._entries[bucket].Key = key;
this._entries[bucket].Value = value;
}
}
public void Clear()
{
this._entries = new Entry[_capacity];
BlockCopyMemoryHelper.Memset(this._entries, new Entry(kUnusedHash, default(TKey), default(TValue)));
this._numberOfUsed = 0;
this._numberOfDeleted = 0;
this._size = 0;
}
public bool Contains(TKey key)
{
Contract.Ensures(this._numberOfUsed <= this._capacity);
if (key == null)
throw new ArgumentNullException("key");
return (Lookup(key) != InvalidNodePosition);
}
private void Grow(int newCapacity)
{
Contract.Requires(newCapacity >= _capacity);
Contract.Ensures((_capacity & (_capacity - 1)) == 0);
var entries = new Entry[newCapacity];
BlockCopyMemoryHelper.Memset(entries, new Entry(kUnusedHash, default(TKey), default(TValue)));
Rehash(entries);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool TryGetValue(TKey key, out TValue value)
{
Contract.Requires(key != null);
Contract.Ensures(this._numberOfUsed <= this._capacity);
int hash = GetInternalHashCode(key);
int bucket = hash % _capacity;
var entries = _entries;
uint nHash;
int numProbes = 1;
do
{
nHash = entries[bucket].Hash;
if (nHash == hash && comparer.Equals(entries[bucket].Key, key))
{
value = entries[bucket].Value;
return true;
}
bucket = (bucket + numProbes) % _capacity;
numProbes++;
}
while (nHash != kUnusedHash);
value = default(TValue);
return false;
}
/// <summary>
///
/// </summary>
/// <param name="key"></param>
/// <returns>Position of the node in the array</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private int Lookup(TKey key)
{
int hash = GetInternalHashCode(key);
int bucket = hash % _capacity;
var entries = _entries;
uint uhash = (uint)hash;
uint numProbes = 1; // how many times we've probed
uint nHash;
do
{
nHash = entries[bucket].Hash;
if (nHash == hash && comparer.Equals(entries[bucket].Key, key))
return bucket;
bucket = (int)((bucket + numProbes) % _capacity);
numProbes++;
}
while (nHash != kUnusedHash);
return InvalidNodePosition;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private int GetInternalHashCode(TKey key)
{
return comparer.GetHashCode(key) & 0x7FFFFFFF;
}
private void Rehash(Entry[] entries)
{
uint capacity = (uint)entries.Length;
var size = 0;
for (int it = 0; it < _entries.Length; it++)
{
uint hash = _entries[it].Hash;
if (hash >= kDeletedHash) // No interest for the process of rehashing, we are skipping it.
continue;
uint bucket = hash % capacity;
uint numProbes = 0;
while (!(entries[bucket].Hash == kUnusedHash))
{
numProbes++;
bucket = (bucket + numProbes) % capacity;
}
entries[bucket].Hash = hash;
entries[bucket].Key = _entries[it].Key;
entries[bucket].Value = _entries[it].Value;
size++;
}
this._capacity = entries.Length;
this._size = size;
this._entries = entries;
this._numberOfUsed = size;
this._numberOfDeleted = 0;
this._nextGrowthThreshold = _capacity * 4 / tLoadFactor;
}
public void CopyTo(KeyValuePair<TKey, TValue>[] array, int index)
{
if (array == null)
throw new ArgumentNullException("The array cannot be null", "array");
if (array.Rank != 1)
throw new ArgumentException("Multiple dimensions array are not supporter", "array");
if (index < 0 || index > array.Length)
throw new ArgumentOutOfRangeException("index");
if (array.Length - index < Count)
throw new ArgumentException("The array plus the offset is too small.");
int count = _capacity;
var entries = _entries;
for (int i = 0; i < count; i++)
{
if (entries[i].Hash < kDeletedHash)
array[index++] = new KeyValuePair<TKey, TValue>(entries[i].Key, entries[i].Value);
}
}
IEnumerator IEnumerable.GetEnumerator()
{
return new Enumerator(this);
}
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
{
return new Enumerator(this);
}
[Serializable]
public struct Enumerator : IEnumerator<KeyValuePair<TKey, TValue>>
{
private FastDictionary<TKey, TValue> dictionary;
private int index;
private KeyValuePair<TKey, TValue> current;
internal const int DictEntry = 1;
internal const int KeyValuePair = 2;
internal Enumerator(FastDictionary<TKey, TValue> dictionary)
{
this.dictionary = dictionary;
this.index = 0;
this.current = new KeyValuePair<TKey, TValue>();
}
public bool MoveNext()
{
var count = dictionary._capacity;
var entries = dictionary._entries;
// Use unsigned comparison since we set index to dictionary.count+1 when the enumeration ends.
// dictionary.count+1 could be negative if dictionary.count is Int32.MaxValue
while (index < count)
{
if (entries[index].Hash < kDeletedHash)
{
current = new KeyValuePair<TKey, TValue>(entries[index].Key, entries[index].Value);
index++;
return true;
}
index++;
}
index = count + 1;
current = new KeyValuePair<TKey, TValue>();
return false;
}
public KeyValuePair<TKey, TValue> Current
{
get { return current; }
}
public void Dispose()
{
}
object IEnumerator.Current
{
get
{
if (index == 0 || (index == dictionary._capacity + 1))
throw new InvalidOperationException("Can't happen.");
return new KeyValuePair<TKey, TValue>(current.Key, current.Value);
}
}
void IEnumerator.Reset()
{
index = 0;
current = new KeyValuePair<TKey, TValue>();
}
}
public KeyCollection Keys
{
get { return new KeyCollection(this); }
}
public ValueCollection Values
{
get { return new ValueCollection(this); }
}
public bool ContainsKey(TKey key)
{
if (key == null)
throw new ArgumentNullException("key");
return (Lookup(key) != InvalidNodePosition);
}
public bool ContainsValue(TValue value)
{
var entries = _entries;
int count = _capacity;
if (value == null)
{
for (int i = 0; i < count; i++)
{
if (entries[i].Hash < kDeletedHash && entries[i].Value == null)
return true;
}
}
else
{
EqualityComparer<TValue> c = EqualityComparer<TValue>.Default;
for (int i = 0; i < count; i++)
{
if (entries[i].Hash < kDeletedHash && c.Equals(entries[i].Value, value))
return true;
}
}
return false;
}
public sealed class KeyCollection : IEnumerable<TKey>, IEnumerable
{
private FastDictionary<TKey, TValue> dictionary;
public KeyCollection(FastDictionary<TKey, TValue> dictionary)
{
Contract.Requires(dictionary != null);
this.dictionary = dictionary;
}
public Enumerator GetEnumerator()
{
return new Enumerator(dictionary);
}
public void CopyTo(TKey[] array, int index)
{
if (array == null)
throw new ArgumentNullException("The array cannot be null", "array");
if (index < 0 || index > array.Length)
throw new ArgumentOutOfRangeException("index");
if (array.Length - index < dictionary.Count)
throw new ArgumentException("The array plus the offset is too small.");
int count = dictionary._capacity;
var entries = dictionary._entries;
for (int i = 0; i < count; i++)
{
if (entries[i].Hash < kDeletedHash)
array[index++] = entries[i].Key;
}
}
public int Count
{
get { return dictionary.Count; }
}
IEnumerator<TKey> IEnumerable<TKey>.GetEnumerator()
{
return new Enumerator(dictionary);
}
IEnumerator IEnumerable.GetEnumerator()
{
return new Enumerator(dictionary);
}
[Serializable]
public struct Enumerator : IEnumerator<TKey>, IEnumerator
{
private FastDictionary<TKey, TValue> dictionary;
private int index;
private TKey currentKey;
internal Enumerator(FastDictionary<TKey, TValue> dictionary)
{
this.dictionary = dictionary;
index = 0;
currentKey = default(TKey);
}
public void Dispose()
{
}
public bool MoveNext()
{
var count = dictionary._capacity;
var entries = dictionary._entries;
while (index < count)
{
if (entries[index].Hash < kDeletedHash)
{
currentKey = entries[index].Key;
index++;
return true;
}
index++;
}
index = count + 1;
currentKey = default(TKey);
return false;
}
public TKey Current
{
get
{
return currentKey;
}
}
Object System.Collections.IEnumerator.Current
{
get
{
if (index == 0 || (index == dictionary.Count + 1))
throw new InvalidOperationException("Cant happen.");
return currentKey;
}
}
void System.Collections.IEnumerator.Reset()
{
index = 0;
currentKey = default(TKey);
}
}
}
public sealed class ValueCollection : IEnumerable<TValue>, IEnumerable
{
private FastDictionary<TKey, TValue> dictionary;
public ValueCollection(FastDictionary<TKey, TValue> dictionary)
{
Contract.Requires(dictionary != null);
this.dictionary = dictionary;
}
public Enumerator GetEnumerator()
{
return new Enumerator(dictionary);
}
public void CopyTo(TValue[] array, int index)
{
if (array == null)
throw new ArgumentNullException("The array cannot be null", "array");
if (index < 0 || index > array.Length)
throw new ArgumentOutOfRangeException("index");
if (array.Length - index < dictionary.Count)
throw new ArgumentException("The array plus the offset is too small.");
int count = dictionary._capacity;
var entries = dictionary._entries;
for (int i = 0; i < count; i++)
{
if (entries[i].Hash < kDeletedHash)
array[index++] = entries[i].Value;
}
}
public int Count
{
get { return dictionary.Count; }
}
IEnumerator<TValue> IEnumerable<TValue>.GetEnumerator()
{
return new Enumerator(dictionary);
}
IEnumerator IEnumerable.GetEnumerator()
{
return new Enumerator(dictionary);
}
[Serializable]
public struct Enumerator : IEnumerator<TValue>, IEnumerator
{
private FastDictionary<TKey, TValue> dictionary;
private int index;
private TValue currentValue;
internal Enumerator(FastDictionary<TKey, TValue> dictionary)
{
this.dictionary = dictionary;
index = 0;
currentValue = default(TValue);
}
public void Dispose()
{
}
public bool MoveNext()
{
var count = dictionary._capacity;
var entries = dictionary._entries;
while (index < count)
{
if (entries[index].Hash < kDeletedHash)
{
currentValue = entries[index].Value;
index++;
return true;
}
index++;
}
index = count + 1;
currentValue = default(TValue);
return false;
}
public TValue Current
{
get
{
return currentValue;
}
}
Object IEnumerator.Current
{
get
{
if (index == 0 || (index == dictionary.Count + 1))
throw new InvalidOperationException("Cant happen.");
return currentValue;
}
}
void IEnumerator.Reset()
{
index = 0;
currentValue = default(TValue);
}
}
}
private class BlockCopyMemoryHelper
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Memset(Entry[] array, Entry value)
{
int block = 64, index = 0;
int length = Math.Min(block, array.Length);
//Fill the initial array
while (index < length)
{
array[index++] = value;
}
length = array.Length;
while (index < length)
{
Array.Copy(array, 0, array, index, Math.Min(block, (length - index)));
index += block;
block *= 2;
}
}
}
}
}

View File

@ -1,192 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Immutable;
namespace BlueWest.Collections
{
/// <summary>
/// very basic wrapper around an array that auto-expands it when it reaches capacity. Note that when iterating it should be done
/// like this accessing the buffer directly but using the FastList.length field:
///
/// for( var i = 0; i &lt;= list.length; i++ )
/// var item = list.buffer[i];
/// </summary>
public class FastList<T>
{
/// <summary>
/// direct access to the backing buffer. Do not use buffer.Length! Use FastList.length
/// </summary>
public T[] Buffer;
/// <summary>
/// direct access to the length of the filled items in the buffer. Do not change.
/// </summary>
public int Length = 0;
public FastList(int size)
{
Buffer = new T[size];
}
public FastList() : this(5)
{
}
/// <summary>
/// provided for ease of access though it is recommended to just access the buffer directly.
/// </summary>
/// <param name="index">Index.</param>
public T this[int index] => Buffer[index];
/// <summary>
/// clears the list and nulls out all items in the buffer
/// </summary>
public void Clear()
{
Array.Clear(Buffer, 0, Length);
Length = 0;
}
/// <summary>
/// works just like clear except it does not null our all the items in the buffer. Useful when dealing with structs.
/// </summary>
public void Reset()
{
Length = 0;
}
/// <summary>
/// adds the item to the list
/// </summary>
public void Add(T item)
{
if (Length == Buffer.Length)
Array.Resize(ref Buffer, Math.Max(Buffer.Length << 1, 10));
Buffer[Length++] = item;
}
/// <summary>
/// removes the item from the list
/// </summary>
/// <param name="item">Item.</param>
public void Remove(T item)
{
var comp = EqualityComparer<T>.Default;
for (var i = 0; i < Length; ++i)
{
if (comp.Equals(Buffer[i], item))
{
RemoveAt(i);
return;
}
}
}
/// <summary>
/// removes the item at the given index from the list
/// </summary>
public void RemoveAt(int index)
{
Length--;
if (index < Length)
Array.Copy(Buffer, index + 1, Buffer, index, Length - index);
Buffer[Length] = default(T);
}
/// <summary>
/// removes the item at the given index from the list but does NOT maintain list order
/// </summary>
/// <param name="index">Index.</param>
public void RemoveAtWithSwap(int index)
{
Buffer[index] = Buffer[Length - 1];
Buffer[Length - 1] = default(T);
--Length;
}
/// <summary>
/// checks to see if item is in the FastList
/// </summary>
/// <param name="item">Item.</param>
public bool Contains(T item)
{
var comp = EqualityComparer<T>.Default;
for (var i = 0; i < Length; ++i)
{
if (comp.Equals(Buffer[i], item))
return true;
}
return false;
}
/// <summary>
/// Converts To a generic List
/// </summary>
/// <param name="item">Item.</param>
public System.Collections.Immutable.ImmutableArray<T> ToList()
{
return Buffer.ToImmutableArray();
}
/// <summary>
/// if the buffer is at its max more space will be allocated to fit additionalItemCount
/// </summary>
public void EnsureCapacity(int additionalItemCount = 1)
{
if (Length + additionalItemCount >= Buffer.Length)
Array.Resize(ref Buffer, Math.Max(Buffer.Length << 1, Length + additionalItemCount));
}
/// <summary>
/// adds all items from array
/// </summary>
/// <param name="array">Array.</param>
public void AddRange(IEnumerable<T> array)
{
foreach (var item in array)
Add(item);
}
/// <summary>
/// sorts all items in the buffer up to length
/// </summary>
public void Sort()
{
Array.Sort(Buffer, 0, Length);
}
/// <summary>
/// sorts all items in the buffer up to length
/// </summary>
public void Sort(IComparer comparer)
{
Array.Sort(Buffer, 0, Length, comparer);
}
/// <summary>
/// sorts all items in the buffer up to length
/// </summary>
public void Sort(IComparer<T> comparer)
{
Array.Sort(Buffer, 0, Length, comparer);
}
}
}

View File

@ -1,57 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
namespace BlueWest.Collections
{
public static class IEnumerableExtensions
{
public static TSource? FirstOrNull<TSource>(this TSource[] source, Func<TSource, bool> predicate) where TSource : struct =>
source.TryGetFirst(predicate);
private static TSource? TryGetFirst<TSource>(this TSource[] source, Func<TSource, bool> predicate) where TSource : struct
{
for (var i = 0; i < source.Length; i++)
{
if (predicate(source[i]))
{
return source[i];
}
}
return null;
}
public static TSource FirstOrNullRef<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate) where TSource : class =>
source.TryGetFirstClass(predicate);
public static TSource? FirstOrNullStruct<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate) where TSource : struct =>
source.TryGetFirstStruct(predicate);
private static TSource? TryGetFirstStruct<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate) where TSource : struct
{
foreach (TSource obj in source)
{
if (predicate(obj))
{
return obj;
}
}
return null;
}
private static TSource TryGetFirstClass<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate) where TSource : class
{
foreach (TSource obj in source)
{
if (predicate(obj))
{
return obj;
}
}
return null;
}
}
}

View File

@ -7,17 +7,10 @@
<AnalysisLevel>preview</AnalysisLevel> <AnalysisLevel>preview</AnalysisLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="MessagePack" Version="2.3.85" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\include\MapTo\src\BlueWest.MapTo\BlueWest.MapTo.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" /> <ProjectReference Include="..\include\MapTo\src\BlueWest.MapTo\BlueWest.MapTo.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
<ProjectReference Include="..\include\Math-Expression-Evaluator\SimpleExpressionEvaluator\SimpleExpressionEvaluator.csproj" /> <ProjectReference Include="..\include\Math-Expression-Evaluator\SimpleExpressionEvaluator\SimpleExpressionEvaluator.csproj" />
</ItemGroup> </ItemGroup>
<Import Project="..\include\MapTo\src\BlueWest.MapTo\MapTo.props" /> <Import Project="..\include\MapTo\src\BlueWest.MapTo\MapTo.props" />
<ItemGroup>
<ProjectReference Include="..\BlueWest.Collections\BlueWest.Collections.csproj" />
</ItemGroup>
</Project> </Project>

View File

@ -9,8 +9,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlueWest.Data", "BlueWest.D
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlueWest.Api", "BlueWest.Api\BlueWest.Api.csproj", "{6D3321B5-CF1A-4251-B28D-329EDA6DC278}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlueWest.Api", "BlueWest.Api\BlueWest.Api.csproj", "{6D3321B5-CF1A-4251-B28D-329EDA6DC278}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlueWest.Collections", "BlueWest.Collections\BlueWest.Collections.csproj", "{F55019A2-E2A8-4AF1-8FBC-FA99476A1B1C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlueWest.MapTo", "include\MapTo\src\BlueWest.MapTo\BlueWest.MapTo.csproj", "{72B37540-A12F-466E-A58F-7BA2B247CB74}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlueWest.MapTo", "include\MapTo\src\BlueWest.MapTo\BlueWest.MapTo.csproj", "{72B37540-A12F-466E-A58F-7BA2B247CB74}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleExpressionEvaluator", "include\Math-Expression-Evaluator\SimpleExpressionEvaluator\SimpleExpressionEvaluator.csproj", "{30637214-EDE9-4C2E-BFD6-E4B163FA308B}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleExpressionEvaluator", "include\Math-Expression-Evaluator\SimpleExpressionEvaluator\SimpleExpressionEvaluator.csproj", "{30637214-EDE9-4C2E-BFD6-E4B163FA308B}"
@ -39,10 +37,6 @@ Global
{6D3321B5-CF1A-4251-B28D-329EDA6DC278}.Debug|Any CPU.Build.0 = Debug|Any CPU {6D3321B5-CF1A-4251-B28D-329EDA6DC278}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6D3321B5-CF1A-4251-B28D-329EDA6DC278}.Release|Any CPU.ActiveCfg = Release|Any CPU {6D3321B5-CF1A-4251-B28D-329EDA6DC278}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6D3321B5-CF1A-4251-B28D-329EDA6DC278}.Release|Any CPU.Build.0 = Release|Any CPU {6D3321B5-CF1A-4251-B28D-329EDA6DC278}.Release|Any CPU.Build.0 = Release|Any CPU
{F55019A2-E2A8-4AF1-8FBC-FA99476A1B1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F55019A2-E2A8-4AF1-8FBC-FA99476A1B1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F55019A2-E2A8-4AF1-8FBC-FA99476A1B1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F55019A2-E2A8-4AF1-8FBC-FA99476A1B1C}.Release|Any CPU.Build.0 = Release|Any CPU
{72B37540-A12F-466E-A58F-7BA2B247CB74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {72B37540-A12F-466E-A58F-7BA2B247CB74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{72B37540-A12F-466E-A58F-7BA2B247CB74}.Debug|Any CPU.Build.0 = Debug|Any CPU {72B37540-A12F-466E-A58F-7BA2B247CB74}.Debug|Any CPU.Build.0 = Debug|Any CPU
{72B37540-A12F-466E-A58F-7BA2B247CB74}.Release|Any CPU.ActiveCfg = Release|Any CPU {72B37540-A12F-466E-A58F-7BA2B247CB74}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -65,7 +59,6 @@ Global
GlobalSection(NestedProjects) = preSolution GlobalSection(NestedProjects) = preSolution
{30637214-EDE9-4C2E-BFD6-E4B163FA308B} = {A1606EEC-6AC5-4779-B140-F57089F5A05F} {30637214-EDE9-4C2E-BFD6-E4B163FA308B} = {A1606EEC-6AC5-4779-B140-F57089F5A05F}
{72B37540-A12F-466E-A58F-7BA2B247CB74} = {A1606EEC-6AC5-4779-B140-F57089F5A05F} {72B37540-A12F-466E-A58F-7BA2B247CB74} = {A1606EEC-6AC5-4779-B140-F57089F5A05F}
{F55019A2-E2A8-4AF1-8FBC-FA99476A1B1C} = {19577B27-7EDF-4DBA-83D5-E047467BDFEF}
{E518C62D-768C-4885-9C9D-FD5761605B54} = {19577B27-7EDF-4DBA-83D5-E047467BDFEF} {E518C62D-768C-4885-9C9D-FD5761605B54} = {19577B27-7EDF-4DBA-83D5-E047467BDFEF}
{08F4484E-5FD8-4590-A8D7-12FBE47120C8} = {A1606EEC-6AC5-4779-B140-F57089F5A05F} {08F4484E-5FD8-4590-A8D7-12FBE47120C8} = {A1606EEC-6AC5-4779-B140-F57089F5A05F}
EndGlobalSection EndGlobalSection

View File

@ -5,17 +5,6 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<ImplicitUsings>disable</ImplicitUsings> <ImplicitUsings>disable</ImplicitUsings>
<RootNamespace>PerformanceSolution</RootNamespace> <RootNamespace>PerformanceSolution</RootNamespace>
<EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\BlueWest.Collections\BlueWest.Collections.csproj" />
<ProjectReference Include="..\BlueWest.Data\BlueWest.Data.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="MessagePack" Version="2.3.85" />
<PackageReference Include="Newtonsoft.Json" Version="6.0.4" />
</ItemGroup>
</Project> </Project>

View File

@ -1,5 +1,5 @@
using System.Collections; using System.Collections;
using BlueWest.Collections; using System.Collections.Generic;
using BlueWest.Coroutines; using BlueWest.Coroutines;
using BlueWest.Tools; using BlueWest.Tools;
@ -11,7 +11,7 @@ namespace BlueWest.Core.ComponentSystem
public bool IsActive { get; private set; } = true; public bool IsActive { get; private set; } = true;
private readonly FastDictionary<int, IEnumerator> _coroutines = new FastDictionary<int, IEnumerator>(10000); private readonly Dictionary<int, IEnumerator> _coroutines = new Dictionary<int, IEnumerator>(10000);
private int _coroutineCount = 0; private int _coroutineCount = 0;

View File

@ -1,16 +1,16 @@
using System; using System;
using BlueWest.Collections; using System.Collections.Generic;
namespace BlueWest.Tools namespace BlueWest.Tools
{ {
public sealed class EventManager public sealed class EventManager
{ {
private readonly FastDictionary<Type, FastList<EventListenerBase>> _subscribersList; private readonly Dictionary<Type, List<EventListenerBase>> _subscribersList;
private static EventManager _instance; private static EventManager _instance;
public EventManager(FastDictionary<Type, FastList<EventListenerBase>> subscribersList) public EventManager(Dictionary<Type, List<EventListenerBase>> subscribersList)
{ {
_subscribersList = subscribersList; _subscribersList = subscribersList;
_instance = this; _instance = this;
@ -26,7 +26,7 @@ namespace BlueWest.Tools
var eventType = typeof( TEvent ); var eventType = typeof( TEvent );
if( !_subscribersList.ContainsKey( eventType ) ) if( !_subscribersList.ContainsKey( eventType ) )
_subscribersList[eventType] = new FastList<EventListenerBase>(10000); _subscribersList[eventType] = new List<EventListenerBase>(10000);
//if( !SubscriptionExists( eventType, listener ) ) //if( !SubscriptionExists( eventType, listener ) )
_subscribersList[eventType].Add( listener ); _subscribersList[eventType].Add( listener );
@ -41,15 +41,15 @@ namespace BlueWest.Tools
{ {
var eventType = typeof( TEvent ); var eventType = typeof( TEvent );
FastList<EventListenerBase> subscriberList = _subscribersList[eventType]; List<EventListenerBase> subscriberList = _subscribersList[eventType];
for (int i = 0; i<subscriberList.Length; i++) for (int i = 0; i<subscriberList.Count; i++)
{ {
if( subscriberList.Buffer[i] == listener ) if( subscriberList[i] == listener )
{ {
subscriberList.Remove( subscriberList[i] ); subscriberList.Remove( subscriberList[i] );
if( subscriberList.Length == 0 ) if( subscriberList.Count == 0 )
_subscribersList.Remove( eventType ); _subscribersList.Remove( eventType );
return; return;
@ -76,11 +76,11 @@ namespace BlueWest.Tools
#endif #endif
FastList<EventListenerBase> list = _subscribersList[type]; List<EventListenerBase> list = _subscribersList[type];
for (int i=0; i<list.Length; i++) for (int i=0; i<list.Count; i++)
{ {
var eventListener = list.Buffer[i]; var eventListener = list[i];
var casted = eventListener as EventListener<TEvent>; var casted = eventListener as EventListener<TEvent>;
casted.OnEvent( newEvent ); casted.OnEvent( newEvent );
} }
@ -94,15 +94,15 @@ namespace BlueWest.Tools
/// <param name="receiver">Receiver.</param> /// <param name="receiver">Receiver.</param>
private bool SubscriptionExists( Type type, EventListenerBase receiver ) private bool SubscriptionExists( Type type, EventListenerBase receiver )
{ {
FastList<EventListenerBase> receivers; List<EventListenerBase> receivers;
if( !_subscribersList.TryGetValue( type, out receivers ) ) return false; if( !_subscribersList.TryGetValue( type, out receivers ) ) return false;
bool exists = false; bool exists = false;
for (int i=0; i<receivers.Length; i++) for (int i=0; i<receivers.Count; i++)
{ {
if( receivers.Buffer[i] == receiver ) if( receivers[i] == receiver )
{ {
exists = true; exists = true;
break; break;

View File

@ -1,15 +1,15 @@
using System; using System;
using BlueWest.Collections; using System.Collections.Generic;
namespace BlueWest.Tools namespace BlueWest.Tools
{ {
public struct EventManagerAsync public struct EventManagerAsync
{ {
private static readonly FastDictionary<Type, FastList<EventListenerBaseAsync>> _subscribersList; private static readonly Dictionary<Type, List<EventListenerBaseAsync>> _subscribersList;
static EventManagerAsync() static EventManagerAsync()
{ {
_subscribersList = new FastDictionary<Type, FastList<EventListenerBaseAsync>>(12412); _subscribersList = new Dictionary<Type, List<EventListenerBaseAsync>>(12412);
} }
/// <suary> /// <suary>
@ -23,7 +23,7 @@ namespace BlueWest.Tools
var eventType = typeof(TEventAsync); var eventType = typeof(TEventAsync);
if (!_subscribersList.ContainsKey(eventType)) if (!_subscribersList.ContainsKey(eventType))
_subscribersList[eventType] = new FastList<EventListenerBaseAsync>(10000); _subscribersList[eventType] = new List<EventListenerBaseAsync>(10000);
//if( !SubscriptionExistsAsync( eventType, listener ) ) //if( !SubscriptionExistsAsync( eventType, listener ) )
_subscribersList[eventType].Add(listener); _subscribersList[eventType].Add(listener);
@ -49,15 +49,15 @@ namespace BlueWest.Tools
#endif #endif
}*/ }*/
FastList<EventListenerBaseAsync> subscriberList = _subscribersList[eventType]; List<EventListenerBaseAsync> subscriberList = _subscribersList[eventType];
for (int i = 0; i < subscriberList.Length; i++) for (int i = 0; i < subscriberList.Count; i++)
{ {
if (subscriberList.Buffer[i] == listener) if (subscriberList[i] == listener)
{ {
subscriberList.Remove(subscriberList[i]); subscriberList.Remove(subscriberList[i]);
if (subscriberList.Length == 0) if (subscriberList.Count == 0)
_subscribersList.Remove(eventType); _subscribersList.Remove(eventType);
return; return;
@ -74,11 +74,11 @@ namespace BlueWest.Tools
{ {
var type = typeof(TEvent); var type = typeof(TEvent);
FastList<EventListenerBaseAsync> list = _subscribersList[type]; List<EventListenerBaseAsync> list = _subscribersList[type];
for (int i = 0; i < list.Length; i++) for (int i = 0; i < list.Count; i++)
{ {
var baseListener = list.Buffer[i]; var baseListener = list[i];
var eventListenerCasted = baseListener as EventListenerAsync<TEvent>; var eventListenerCasted = baseListener as EventListenerAsync<TEvent>;
eventListenerCasted.OnEventAsync(newEvent); eventListenerCasted.OnEventAsync(newEvent);
} }
@ -92,15 +92,15 @@ namespace BlueWest.Tools
/// <param name="receiver">Receiver.</param> /// <param name="receiver">Receiver.</param>
private static bool SubscriptionExistsAsync(Type type, EventListenerBaseAsync receiver) private static bool SubscriptionExistsAsync(Type type, EventListenerBaseAsync receiver)
{ {
FastList<EventListenerBaseAsync> receivers; List<EventListenerBaseAsync> receivers;
if (!_subscribersList.TryGetValue(type, out receivers)) return false; if (!_subscribersList.TryGetValue(type, out receivers)) return false;
bool exists = false; bool exists = false;
for (int i = 0; i < receivers.Length; i++) for (int i = 0; i < receivers.Count; i++)
{ {
var eventListenerBase = receivers.Buffer[i]; var eventListenerBase = receivers[i];
if (eventListenerBase == receiver) if (eventListenerBase == receiver)
{ {
return true; return true;

View File

@ -1,8 +1,8 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic;
using System.Data; using System.Data;
using System.Threading; using System.Threading;
using BlueWest.Collections;
using BlueWest.Coroutines; using BlueWest.Coroutines;
using BlueWest.Tools; using BlueWest.Tools;
@ -41,11 +41,11 @@ namespace BlueWest.Core.ComponentSystem
private readonly TimerTick _autoTickTimer; private readonly TimerTick _autoTickTimer;
private TimeSpan accumulatedElapsedGameTime; private TimeSpan accumulatedElapsedGameTime;
private FastDictionary<ArtefactFrequency, int> behaviorConfigType = private Dictionary<ArtefactFrequency, int> behaviorConfigType =
new FastDictionary<ArtefactFrequency, int>(10); new Dictionary<ArtefactFrequency, int>(10);
private readonly FastList<IEnumerator> _coroutines = new FastList<IEnumerator>(10000); private readonly List<IEnumerator> _coroutines = new List<IEnumerator>(10000);
private bool? _prevVisibility; private bool? _prevVisibility;
// Mini ECS // Mini ECS
protected EventManager _eventManager; protected EventManager _eventManager;
@ -55,7 +55,7 @@ namespace BlueWest.Core.ComponentSystem
internal VisibilityHandler _visibilityHandler = new VisibilityHandler(); internal VisibilityHandler _visibilityHandler = new VisibilityHandler();
internal FastList<Component> _components = new FastList<Component>(10); internal List<Component> _components = new List<Component>(10);
private int _componentsCount = 0; private int _componentsCount = 0;
@ -149,9 +149,9 @@ namespace BlueWest.Core.ComponentSystem
public void ProcessComponents(double delta) public void ProcessComponents(double delta)
{ {
for (int i = 0; i < _components.Length; i++) for (int i = 0; i < _components.Count; i++)
{ {
var component = _components.Buffer[i]; var component = _components[i];
component.EveryFrame(delta); component.EveryFrame(delta);
component.HandleCoroutines(); component.HandleCoroutines();
} }
@ -226,11 +226,11 @@ namespace BlueWest.Core.ComponentSystem
public void HandleCoroutines() public void HandleCoroutines()
{ {
for (var i = 0; i < _coroutines.Length; i++) for (var i = 0; i < _coroutines.Count; i++)
{ {
var yielded = _coroutines.Buffer[i].Current is CustomYieldInstruction yielder && yielder.MoveNext(); var yielded = _coroutines[i].Current is CustomYieldInstruction yielder && yielder.MoveNext();
if (yielded || _coroutines.Buffer[i].MoveNext()) continue; if (yielded || _coroutines[i].MoveNext()) continue;
_coroutines.RemoveAt(i); _coroutines.RemoveAt(i);
i--; i--;
} }

View File

@ -1,5 +1,5 @@
using System; using System;
using BlueWest.Collections; using System.Collections.Generic;
using BlueWest.Tools; using BlueWest.Tools;
using BlueWest.Core.Threading; using BlueWest.Core.Threading;
@ -9,7 +9,7 @@ namespace BlueWest.Core
public sealed class BlueProgram public sealed class BlueProgram
{ {
private static readonly FastDictionary<Type, FastList<EventListenerBase>> Events = new(10000); private static readonly Dictionary<Type, List<EventListenerBase>> Events = new(10000);
private static readonly EventManager EventManager = new(Events); private static readonly EventManager EventManager = new(Events);

View File

@ -2,7 +2,6 @@
using System.Collections; using System.Collections;
using System.IO; using System.IO;
using System.Runtime.Serialization.Formatters.Binary; using System.Runtime.Serialization.Formatters.Binary;
using MessagePack;
using Directory = System.IO.Directory; using Directory = System.IO.Directory;
using File = System.IO.File; using File = System.IO.File;
@ -70,12 +69,12 @@ namespace PerformanceSolution.Tools
} }
// we serialize and write our object into a file on disk // we serialize and write our object into a file on disk
var byteData = MessagePackSerializer.Serialize(saveObject); //var byteData = MessagePackSerializer.Serialize(saveObject);
File.WriteAllText(savePath + saveFileName + ".json", saveObject.ToString()); File.WriteAllText(savePath + saveFileName + ".json", saveObject.ToString());
File.WriteAllBytes(savePath + saveFileName, byteData); //File.WriteAllBytes(savePath + saveFileName, byteData);
} }
/// <summary> /// <summary>
@ -98,9 +97,10 @@ namespace PerformanceSolution.Tools
byte[] readByte = File.ReadAllBytes(saveFileName); byte[] readByte = File.ReadAllBytes(saveFileName);
var finalObject = MessagePackSerializer.Deserialize<T>(readByte); //var finalObject = MessagePackSerializer.Deserialize<T>(readByte);
return finalObject; //return finalObject;
return null;
} }
/// <summary> /// <summary>

28
Dockerfile Normal file
View File

@ -0,0 +1,28 @@
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
#COPY BlueWest/*.csproj ./BlueWest/
#COPY BlueWest.Api/*.csproj ./BlueWest.Api/
#COPY BlueWest.Data/*.csproj ./BlueWest.Data/
#
#COPY include/Math-Expression-Evaluator/SimpleExpressionEvaluator/*.csproj ./include/Math-Expression-Evaluator/SimpleExpressionEvaluator/
#COPY include/Math-Expression-Evaluator/SimpleExpressionEvaluator.Tests/*.csproj ./include/Math-Expression-Evaluator/SimpleExpressionEvaluator.Tests/
#COPY include/MapTo/src/BlueWest.MapTo/*.csproj ./include/MapTo/src/BlueWest.MapTo/
#COPY include/MapTo/src/BlueWest.MapTo/MapTo.props ./include/MapTo/src/BlueWest.MapTo/
COPY ["BlueWest.Api/BlueWest.Api.csproj", "BlueWest.Api/"]
RUN dotnet restore "BlueWest.Api/BlueWest.Api.csproj"
COPY . .
WORKDIR "/src/BlueWest.Api"
RUN dotnet build "BlueWest.Api.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "BlueWest.Api.csproj" -c Release -o /app/publish --self-contained false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "BlueWest.Api.dll"]

30
Dockerfile_old Normal file
View File

@ -0,0 +1,30 @@
# https://hub.docker.com/_/microsoft-dotnet
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /source
# copy csproj and restore as distinct layers
COPY *.sln .
COPY BlueWest/*.csproj ./BlueWest/
COPY BlueWest.Api/*.csproj ./BlueWest.Api/
COPY BlueWest.Data/*.csproj ./BlueWest.Data/
COPY include/Math-Expression-Evaluator/SimpleExpressionEvaluator/*.csproj ./include/Math-Expression-Evaluator/SimpleExpressionEvaluator/
COPY include/Math-Expression-Evaluator/SimpleExpressionEvaluator.Tests/*.csproj ./include/Math-Expression-Evaluator/SimpleExpressionEvaluator.Tests/
COPY include/MapTo/src/BlueWest.MapTo/*.csproj ./include/MapTo/src/BlueWest.MapTo/
COPY include/MapTo/src/BlueWest.MapTo/MapTo.props ./include/MapTo/src/BlueWest.MapTo/
RUN dotnet restore
# copy everything else and build app
COPY BlueWest/. ./BlueWest/
WORKDIR /source/BlueWest.Api
#RUN dotnet publish -c release -o /app --no-restore
RUN mkdir -p xo
RUN dotnet publish "BlueWest.Api.csproj" -c Release -o xo --no-restore
workdir xo
# final stage/image
FROM mcr.microsoft.com/dotnet/aspnet:6.0
ENTRYPOINT ["dotnet", "BlueWest.Api.dll"]

@ -1 +1 @@
Subproject commit 77603643b4940caf1d896a40dfa0a1258586c936 Subproject commit ca82e6fb176f47105cf1934ba2f9ea42362e11bf

@ -1 +1 @@
Subproject commit bc7ff8bced98c9e58ae1b55133909cd76effb210 Subproject commit 0761d24843de941c47010bf796c60b610e738735