From c82d2e61170357434748e10a37624af467bbe289 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 19 Oct 2025 14:54:31 +0800 Subject: [PATCH 01/19] =?UTF-8?q?chore:=20=E5=A2=9E=E5=8A=A0=20slnx=20?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=96=B9=E6=A1=88=E5=B7=A5=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- binding/csharp/IP2Region.Net.slnx | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 binding/csharp/IP2Region.Net.slnx diff --git a/binding/csharp/IP2Region.Net.slnx b/binding/csharp/IP2Region.Net.slnx new file mode 100644 index 0000000..a4663b7 --- /dev/null +++ b/binding/csharp/IP2Region.Net.slnx @@ -0,0 +1,5 @@ + + + + + From d1715c75f6a4263909954888d40f1f9334d12bf3 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 19 Oct 2025 14:54:49 +0800 Subject: [PATCH 02/19] =?UTF-8?q?refactor:=20=E6=9B=B4=E6=96=B0=20xdb=20?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IP2Region.Net.BenchMark/IP2Region.Net.BenchMark.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/binding/csharp/IP2Region.Net.BenchMark/IP2Region.Net.BenchMark.csproj b/binding/csharp/IP2Region.Net.BenchMark/IP2Region.Net.BenchMark.csproj index 9a77e8c..7acf40f 100644 --- a/binding/csharp/IP2Region.Net.BenchMark/IP2Region.Net.BenchMark.csproj +++ b/binding/csharp/IP2Region.Net.BenchMark/IP2Region.Net.BenchMark.csproj @@ -17,7 +17,7 @@ - + IP2Region/ip2region.xdb PreserveNewest From 7e4d37b1db121b79cb1e5e5bf6ae6d3224d0e355 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 19 Oct 2025 14:55:21 +0800 Subject: [PATCH 03/19] =?UTF-8?q?refactor:=20=E5=A2=9E=E5=8A=A0=E6=9B=B4?= =?UTF-8?q?=E5=A4=9A=E6=A1=86=E6=9E=B6=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../csharp/IP2Region.Net/IP2Region.Net.csproj | 33 +++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/binding/csharp/IP2Region.Net/IP2Region.Net.csproj b/binding/csharp/IP2Region.Net/IP2Region.Net.csproj index 372dd42..ec3c106 100644 --- a/binding/csharp/IP2Region.Net/IP2Region.Net.csproj +++ b/binding/csharp/IP2Region.Net/IP2Region.Net.csproj @@ -2,7 +2,7 @@ IP2Region.Net - 2.0.2 + 2.1.0 IP2Region.Net Alan Lee Apache-2.0 @@ -15,17 +15,44 @@ git enable enable - netstandard2.0;netstandard2.1;net6.0;net7.0 - 10.0 + netstandard2.0;netstandard2.1;net6.0;net7.0;net8.0;net9.0 + latest c2f07fe1-a300-4de3-8200-1278ed8cb5b7 + + + + + + + + + + + + + + + + + + + + + + + + + + + CHANGELOG.md From 2662fb05c27163c8d14adf903b1f66a0e0027e10 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 19 Oct 2025 14:55:37 +0800 Subject: [PATCH 04/19] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E6=B3=A8?= =?UTF-8?q?=E5=85=A5=E6=9C=8D=E5=8A=A1=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Extensions/ServiceCollectionExtensions.cs | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 binding/csharp/IP2Region.Net/Extensions/ServiceCollectionExtensions.cs diff --git a/binding/csharp/IP2Region.Net/Extensions/ServiceCollectionExtensions.cs b/binding/csharp/IP2Region.Net/Extensions/ServiceCollectionExtensions.cs new file mode 100644 index 0000000..eeacdb3 --- /dev/null +++ b/binding/csharp/IP2Region.Net/Extensions/ServiceCollectionExtensions.cs @@ -0,0 +1,27 @@ +using IP2Region.Net.Abstractions; +using IP2Region.Net.XDB; + +namespace Microsoft.Extensions.DependencyInjection; + +/// +/// BootstrapBlazor 服务扩展类 +/// +public static class BootstrapBlazoIP2RegionExtensions +{ + /// + /// 添加 IP2RegionService 服务 + /// + /// + public static IServiceCollection AddIP2RegionService(this IServiceCollection services, string path, CachePolicy cachePolicy = CachePolicy.Content) + { + services.AddSingleton( provider => + { + return new Searcher(cachePolicy, path); + }); +#if NET8_0_OR_GREATER + services.AddKeyedSingleton("IP2Region.Net"); +#endif + + return services; + } +} From 24dcb24e2431c632d37ce67b2c6df1eb1d2d64a7 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 19 Oct 2025 15:08:16 +0800 Subject: [PATCH 05/19] =?UTF-8?q?refactor:=20=E5=A2=9E=E5=8A=A0=20Keyed=20?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Extensions/ServiceCollectionExtensions.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/binding/csharp/IP2Region.Net/Extensions/ServiceCollectionExtensions.cs b/binding/csharp/IP2Region.Net/Extensions/ServiceCollectionExtensions.cs index eeacdb3..dfd4518 100644 --- a/binding/csharp/IP2Region.Net/Extensions/ServiceCollectionExtensions.cs +++ b/binding/csharp/IP2Region.Net/Extensions/ServiceCollectionExtensions.cs @@ -14,12 +14,15 @@ public static class BootstrapBlazoIP2RegionExtensions /// public static IServiceCollection AddIP2RegionService(this IServiceCollection services, string path, CachePolicy cachePolicy = CachePolicy.Content) { - services.AddSingleton( provider => + services.AddSingleton(provider => { return new Searcher(cachePolicy, path); }); #if NET8_0_OR_GREATER - services.AddKeyedSingleton("IP2Region.Net"); + services.AddKeyedSingleton("IP2Region.Net", (provider, _) => + { + return new Searcher(cachePolicy, path); + }); #endif return services; From f594838784e7bf4416bf352db5f93d27aa075066 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 19 Oct 2025 15:09:06 +0800 Subject: [PATCH 06/19] =?UTF-8?q?refactor:=20=E6=9B=B4=E6=94=B9=E6=89=A9?= =?UTF-8?q?=E5=B1=95=E7=B1=BB=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IP2Region.Net/Extensions/ServiceCollectionExtensions.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/binding/csharp/IP2Region.Net/Extensions/ServiceCollectionExtensions.cs b/binding/csharp/IP2Region.Net/Extensions/ServiceCollectionExtensions.cs index dfd4518..3ef335e 100644 --- a/binding/csharp/IP2Region.Net/Extensions/ServiceCollectionExtensions.cs +++ b/binding/csharp/IP2Region.Net/Extensions/ServiceCollectionExtensions.cs @@ -4,9 +4,9 @@ using IP2Region.Net.XDB; namespace Microsoft.Extensions.DependencyInjection; /// -/// BootstrapBlazor 服务扩展类 +/// IP2Region 服务扩展类 /// -public static class BootstrapBlazoIP2RegionExtensions +public static class IP2RegionExtensions { /// /// 添加 IP2RegionService 服务 From 9e979efd7b9f3421f8d7f61c9ccc980b801bf19c Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 19 Oct 2025 15:11:58 +0800 Subject: [PATCH 07/19] =?UTF-8?q?refactor:=20=E6=9B=B4=E6=96=B0=20link=20?= =?UTF-8?q?=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IP2Region.Net.BenchMark/IP2Region.Net.BenchMark.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/binding/csharp/IP2Region.Net.BenchMark/IP2Region.Net.BenchMark.csproj b/binding/csharp/IP2Region.Net.BenchMark/IP2Region.Net.BenchMark.csproj index 7acf40f..6a25b56 100644 --- a/binding/csharp/IP2Region.Net.BenchMark/IP2Region.Net.BenchMark.csproj +++ b/binding/csharp/IP2Region.Net.BenchMark/IP2Region.Net.BenchMark.csproj @@ -18,7 +18,7 @@ - IP2Region/ip2region.xdb + IP2Region/ip2region_v4.xdb PreserveNewest From 6ad1e8e2e20604b0fcd3b0e12cc7c107216b1f6b Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 19 Oct 2025 15:16:23 +0800 Subject: [PATCH 08/19] =?UTF-8?q?test:=20=E6=9B=B4=E6=96=B0=E5=8D=95?= =?UTF-8?q?=E5=85=83=E6=B5=8B=E8=AF=95=20xdb=20=E6=96=87=E4=BB=B6=E8=B7=AF?= =?UTF-8?q?=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- binding/csharp/IP2Region.Net.Test/IP2Region.Net.Test.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/binding/csharp/IP2Region.Net.Test/IP2Region.Net.Test.csproj b/binding/csharp/IP2Region.Net.Test/IP2Region.Net.Test.csproj index e8a9f28..a28ea7c 100644 --- a/binding/csharp/IP2Region.Net.Test/IP2Region.Net.Test.csproj +++ b/binding/csharp/IP2Region.Net.Test/IP2Region.Net.Test.csproj @@ -25,8 +25,8 @@ TestData/ip.merge.txt PreserveNewest - - TestData/ip2region.xdb + + TestData/ip2region_v4.xdb PreserveNewest From 0caff12306f80d72f8dc4b78aa712d09e623b9a7 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 19 Oct 2025 15:16:39 +0800 Subject: [PATCH 09/19] =?UTF-8?q?chore:=20=E6=9B=B4=E6=96=B0=E4=BE=9D?= =?UTF-8?q?=E8=B5=96=E5=8C=85=E7=89=88=E6=9C=AC=E5=8F=B7=E4=B8=BA=E5=85=B7?= =?UTF-8?q?=E4=BD=93=E7=89=88=E6=9C=AC=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- binding/csharp/IP2Region.Net/IP2Region.Net.csproj | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/binding/csharp/IP2Region.Net/IP2Region.Net.csproj b/binding/csharp/IP2Region.Net/IP2Region.Net.csproj index ec3c106..9310ba5 100644 --- a/binding/csharp/IP2Region.Net/IP2Region.Net.csproj +++ b/binding/csharp/IP2Region.Net/IP2Region.Net.csproj @@ -30,27 +30,27 @@ - + - + - + - + - + - + From b94123fee361c011f1bc087745dcb680807bf362 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 19 Oct 2025 15:19:00 +0800 Subject: [PATCH 10/19] =?UTF-8?q?refactor:=20=E9=87=8D=E6=9E=84=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IP2Region.Net/Extensions/ServiceCollectionExtensions.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/binding/csharp/IP2Region.Net/Extensions/ServiceCollectionExtensions.cs b/binding/csharp/IP2Region.Net/Extensions/ServiceCollectionExtensions.cs index 3ef335e..7a2f0f4 100644 --- a/binding/csharp/IP2Region.Net/Extensions/ServiceCollectionExtensions.cs +++ b/binding/csharp/IP2Region.Net/Extensions/ServiceCollectionExtensions.cs @@ -19,9 +19,9 @@ public static class IP2RegionExtensions return new Searcher(cachePolicy, path); }); #if NET8_0_OR_GREATER - services.AddKeyedSingleton("IP2Region.Net", (provider, _) => + services.AddKeyedSingleton("IP2Region.Net", (provider, _) => { - return new Searcher(cachePolicy, path); + return provider.GetRequiredService(); }); #endif From 6aab24fb88ebebb6046529cb3c5931f90d049cd3 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 19 Oct 2025 15:24:39 +0800 Subject: [PATCH 11/19] =?UTF-8?q?refactor:=20=E6=9B=B4=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=20TryAddSingleton=20=E9=98=B2=E6=AD=A2=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E6=B3=A8=E5=86=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IP2Region.Net/Extensions/ServiceCollectionExtensions.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/binding/csharp/IP2Region.Net/Extensions/ServiceCollectionExtensions.cs b/binding/csharp/IP2Region.Net/Extensions/ServiceCollectionExtensions.cs index 7a2f0f4..6f4ddde 100644 --- a/binding/csharp/IP2Region.Net/Extensions/ServiceCollectionExtensions.cs +++ b/binding/csharp/IP2Region.Net/Extensions/ServiceCollectionExtensions.cs @@ -1,5 +1,6 @@ using IP2Region.Net.Abstractions; using IP2Region.Net.XDB; +using Microsoft.Extensions.DependencyInjection.Extensions; namespace Microsoft.Extensions.DependencyInjection; @@ -14,12 +15,12 @@ public static class IP2RegionExtensions /// public static IServiceCollection AddIP2RegionService(this IServiceCollection services, string path, CachePolicy cachePolicy = CachePolicy.Content) { - services.AddSingleton(provider => + services.TryAddSingleton(provider => { return new Searcher(cachePolicy, path); }); #if NET8_0_OR_GREATER - services.AddKeyedSingleton("IP2Region.Net", (provider, _) => + services.TryAddKeyedSingleton("IP2Region.Net", (provider, _) => { return provider.GetRequiredService(); }); From 2ac7655f620812285c948b6045d626dc187bdec5 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 19 Oct 2025 15:30:26 +0800 Subject: [PATCH 12/19] =?UTF-8?q?chore:=20=E6=9B=B4=E6=94=B9=E4=BE=9D?= =?UTF-8?q?=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- binding/csharp/IP2Region.Net/IP2Region.Net.csproj | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/binding/csharp/IP2Region.Net/IP2Region.Net.csproj b/binding/csharp/IP2Region.Net/IP2Region.Net.csproj index 9310ba5..badc071 100644 --- a/binding/csharp/IP2Region.Net/IP2Region.Net.csproj +++ b/binding/csharp/IP2Region.Net/IP2Region.Net.csproj @@ -30,27 +30,27 @@ - + - + - + - + - + - + From 0ad3172f2e9c229d0accda5fb41208999761a8a0 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 19 Oct 2025 15:30:34 +0800 Subject: [PATCH 13/19] =?UTF-8?q?doc:=20=E5=A2=9E=E5=8A=A0=E6=B3=A8?= =?UTF-8?q?=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IP2Region.Net/Extensions/ServiceCollectionExtensions.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/binding/csharp/IP2Region.Net/Extensions/ServiceCollectionExtensions.cs b/binding/csharp/IP2Region.Net/Extensions/ServiceCollectionExtensions.cs index 6f4ddde..980243a 100644 --- a/binding/csharp/IP2Region.Net/Extensions/ServiceCollectionExtensions.cs +++ b/binding/csharp/IP2Region.Net/Extensions/ServiceCollectionExtensions.cs @@ -10,9 +10,11 @@ namespace Microsoft.Extensions.DependencyInjection; public static class IP2RegionExtensions { /// - /// 添加 IP2RegionService 服务 + /// 添加 IP2RegionService 服务。 /// - /// + /// 集合 + /// IP2Region 数据库文件的路径。 + /// 缓存策略,默认为 。 public static IServiceCollection AddIP2RegionService(this IServiceCollection services, string path, CachePolicy cachePolicy = CachePolicy.Content) { services.TryAddSingleton(provider => From 2fe8032d8bacfb3887817956eff0914c5a8733de Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 19 Oct 2025 17:35:37 +0800 Subject: [PATCH 14/19] =?UTF-8?q?chore:=20=E6=9B=B4=E6=94=B9=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E6=A1=86=E6=9E=B6=E4=B8=BA=20net9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IP2Region.Net.BenchMark/IP2Region.Net.BenchMark.csproj | 2 +- binding/csharp/IP2Region.Net.Test/IP2Region.Net.Test.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/binding/csharp/IP2Region.Net.BenchMark/IP2Region.Net.BenchMark.csproj b/binding/csharp/IP2Region.Net.BenchMark/IP2Region.Net.BenchMark.csproj index 6a25b56..8d4f436 100644 --- a/binding/csharp/IP2Region.Net.BenchMark/IP2Region.Net.BenchMark.csproj +++ b/binding/csharp/IP2Region.Net.BenchMark/IP2Region.Net.BenchMark.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net9.0 enable enable diff --git a/binding/csharp/IP2Region.Net.Test/IP2Region.Net.Test.csproj b/binding/csharp/IP2Region.Net.Test/IP2Region.Net.Test.csproj index a28ea7c..9e40761 100644 --- a/binding/csharp/IP2Region.Net.Test/IP2Region.Net.Test.csproj +++ b/binding/csharp/IP2Region.Net.Test/IP2Region.Net.Test.csproj @@ -1,7 +1,7 @@ - net6.0 + net9.0 enable enable From 35e505bd7419ea4fd22f630a62f4e07876b4c85c Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 19 Oct 2025 17:36:03 +0800 Subject: [PATCH 15/19] =?UTF-8?q?test:=20=E6=9B=B4=E6=96=B0=E5=8D=95?= =?UTF-8?q?=E5=85=83=E6=B5=8B=E8=AF=95=E4=BE=9D=E8=B5=96=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- binding/csharp/IP2Region.Net.Test/IP2Region.Net.Test.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/binding/csharp/IP2Region.Net.Test/IP2Region.Net.Test.csproj b/binding/csharp/IP2Region.Net.Test/IP2Region.Net.Test.csproj index 9e40761..bd7c233 100644 --- a/binding/csharp/IP2Region.Net.Test/IP2Region.Net.Test.csproj +++ b/binding/csharp/IP2Region.Net.Test/IP2Region.Net.Test.csproj @@ -21,8 +21,8 @@ - - TestData/ip.merge.txt + + TestData/ipv4_source.txt PreserveNewest From 444b2036d1d9ee75bdd2c82be048720e3523ff1c Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 19 Oct 2025 17:36:37 +0800 Subject: [PATCH 16/19] =?UTF-8?q?chore:=20=E6=9B=B4=E6=96=B0=E5=9F=BA?= =?UTF-8?q?=E5=87=86=E6=B5=8B=E8=AF=95=E6=96=87=E4=BB=B6=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- binding/csharp/IP2Region.Net.BenchMark/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/binding/csharp/IP2Region.Net.BenchMark/Program.cs b/binding/csharp/IP2Region.Net.BenchMark/Program.cs index c8c14e6..b079b8a 100644 --- a/binding/csharp/IP2Region.Net.BenchMark/Program.cs +++ b/binding/csharp/IP2Region.Net.BenchMark/Program.cs @@ -7,7 +7,7 @@ BenchmarkRunner.Run(typeof(Program).Assembly); public class CachePolicyCompare { - private static readonly string XdbPath = Path.Combine(AppContext.BaseDirectory, "IP2Region", "ip2region.xdb"); + private static readonly string XdbPath = Path.Combine(AppContext.BaseDirectory, "IP2Region", "ip2region_v4.xdb"); private readonly ISearcher _contentSearcher = new Searcher(CachePolicy.Content, XdbPath); private readonly ISearcher _vectorSearcher = new Searcher(CachePolicy.VectorIndex,XdbPath); private readonly ISearcher _fileSearcher = new Searcher(CachePolicy.File,XdbPath); From 5deb6d6553f6287e882f84b9abc077e2e966abfb Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 19 Oct 2025 17:36:57 +0800 Subject: [PATCH 17/19] =?UTF-8?q?test:=20=E6=9B=B4=E6=96=B0=E4=BE=9D?= =?UTF-8?q?=E8=B5=96=E6=96=87=E4=BB=B6=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- binding/csharp/IP2Region.Net.Test/SearcherTest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/binding/csharp/IP2Region.Net.Test/SearcherTest.cs b/binding/csharp/IP2Region.Net.Test/SearcherTest.cs index 87337ff..21aa767 100644 --- a/binding/csharp/IP2Region.Net.Test/SearcherTest.cs +++ b/binding/csharp/IP2Region.Net.Test/SearcherTest.cs @@ -5,7 +5,7 @@ namespace IP2Region.Net.Test; [TestFixture] public class SearcherTest { - private readonly string _xdbPath = Path.Combine(AppContext.BaseDirectory, "TestData", "ip2region.xdb"); + private readonly string _xdbPath = Path.Combine(AppContext.BaseDirectory, "TestData", "ip2region_v4.xdb"); public static IEnumerable Ips() { @@ -49,7 +49,7 @@ public class SearcherTest public void TestBenchSearch(CachePolicy cachePolicy) { Searcher searcher = new Searcher(cachePolicy,_xdbPath); - var srcPath = Path.Combine(AppContext.BaseDirectory, "TestData", "ip.merge.txt"); + var srcPath = Path.Combine(AppContext.BaseDirectory, "TestData", "ipv4_source.txt"); foreach (var line in File.ReadLines(srcPath)) { From 1ad01ff98b8dbfade0aa5ad7d2e3d3d9c4239852 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 19 Oct 2025 17:37:09 +0800 Subject: [PATCH 18/19] =?UTF-8?q?doc:=20=E6=9B=B4=E6=96=B0=20readme=20?= =?UTF-8?q?=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- binding/csharp/IP2Region.Net.slnx | 3 +++ binding/csharp/README.md | 27 ++++++++++++++++----------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/binding/csharp/IP2Region.Net.slnx b/binding/csharp/IP2Region.Net.slnx index a4663b7..559f5de 100644 --- a/binding/csharp/IP2Region.Net.slnx +++ b/binding/csharp/IP2Region.Net.slnx @@ -1,4 +1,7 @@ + + + diff --git a/binding/csharp/README.md b/binding/csharp/README.md index 8f8c78c..f203c57 100644 --- a/binding/csharp/README.md +++ b/binding/csharp/README.md @@ -30,28 +30,33 @@ Generate using [maker](https://github.com/lionsoul2014/ip2region/tree/master/mak ## ASP.NET Core Usage ```csharp -services.AddSingleton(new Searcher(CachePolicy , "your xdb file path")); +services.AddIP2RegionService("your xdb file path", cachePolicy: CachePolicy.Content); +``` + +NET6/7 +```csharp +provider.GetRequiredService() +``` + +NET8+ support keyed service +```csharp +provider.GetRequiredKeyedService("IP2Region.Net"); ``` ## Performance ``` ini - BenchmarkDotNet=v0.13.2, OS=macOS 13.4.1 (c) (22F770820d) [Darwin 22.5.0] Apple M1, 1 CPU, 8 logical and 8 physical cores .NET SDK=7.0.306 [Host] : .NET 6.0.20 (6.0.2023.32017), Arm64 RyuJIT AdvSIMD DefaultJob : .NET 6.0.20 (6.0.2023.32017), Arm64 RyuJIT AdvSIMD - - ``` -| Method | Mean | Error | StdDev | -|-------------------------|-----------:|---------:|---------:| -| CachePolicy_Content | 155.7 ns | 0.46 ns | 0.39 ns | -| CachePolicy_File | 2,186.8 ns | 34.27 ns | 32.06 ns | -| CachePolicy_VectorIndex | 1,570.3 ns | 27.53 ns | 22.99 ns | - - +| Method | Mean | Error | StdDev | +|------------------------ |-------------:|----------:|----------:| +| CachePolicy_Content | 58.32 ns | 0.182 ns | 0.170 ns | +| CachePolicy_File | 16,417.56 ns | 50.569 ns | 47.302 ns | +| CachePolicy_VectorIndex | 9,348.11 ns | 38.492 ns | 65.363 ns | ## Contributing Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. From d362231ae87f7a0705cc6b9d82cc6ea2381dabcc Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 19 Oct 2025 17:37:18 +0800 Subject: [PATCH 19/19] =?UTF-8?q?test:=20=E6=9B=B4=E6=96=B0=E4=BE=9D?= =?UTF-8?q?=E8=B5=96=E5=88=B0=E6=9C=80=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IP2Region.Net.Test.csproj | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/binding/csharp/IP2Region.Net.Test/IP2Region.Net.Test.csproj b/binding/csharp/IP2Region.Net.Test/IP2Region.Net.Test.csproj index bd7c233..c2dd005 100644 --- a/binding/csharp/IP2Region.Net.Test/IP2Region.Net.Test.csproj +++ b/binding/csharp/IP2Region.Net.Test/IP2Region.Net.Test.csproj @@ -1,4 +1,4 @@ - + net9.0 @@ -9,11 +9,17 @@ - - - - - + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive +