mirror of
https://github.com/lionsoul2014/ip2region.git
synced 2025-12-08 19:25:22 +00:00
feat: support netstandard2.0
This commit is contained in:
parent
edaca47635
commit
769f708b16
@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<id>IP2Region.Net</id>
|
||||
<version>2.0.0</version>
|
||||
<version>2.0.1</version>
|
||||
<title>IP2Region.Net</title>
|
||||
<authors>Alan Lee</authors>
|
||||
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
|
||||
@ -15,10 +15,20 @@
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<TargetFrameworks>net6.0;netstandard2.1</TargetFrameworks>
|
||||
<TargetFrameworks>netstandard2.0;netstandard2.1;net6.0;net7.0</TargetFrameworks>
|
||||
<LangVersion>10.0</LangVersion>
|
||||
<UserSecretsId>c2f07fe1-a300-4de3-8200-1278ed8cb5b7</UserSecretsId>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\README.md" Pack="true" PackagePath="\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
|
||||
<PackageReference Include="System.Buffers" Version="4.5.1" />
|
||||
<PackageReference Include="System.Memory" Version="4.5.5" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="..\CHANGELOG.md">
|
||||
<Link>CHANGELOG.md</Link>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@ -42,7 +42,7 @@ public class Searcher : ISearcher
|
||||
{
|
||||
var index = _cacheStrategy.GetVectorIndex(ip);
|
||||
uint sPtr = MemoryMarshal.Read<uint>(index.Span);
|
||||
uint ePtr = MemoryMarshal.Read<uint>(index.Span[4..]);
|
||||
uint ePtr = MemoryMarshal.Read<uint>(index.Span.Slice(4));
|
||||
|
||||
var dataLen = 0;
|
||||
uint dataPtr = 0;
|
||||
@ -56,7 +56,7 @@ public class Searcher : ISearcher
|
||||
|
||||
var buffer = _cacheStrategy.GetData((int)pos, SegmentIndexSize);
|
||||
uint sip = MemoryMarshal.Read<uint>(buffer.Span);
|
||||
uint eip = MemoryMarshal.Read<uint>(buffer.Span[4..]);
|
||||
uint eip = MemoryMarshal.Read<uint>(buffer.Span.Slice(4));
|
||||
|
||||
if (ip < sip)
|
||||
{
|
||||
@ -68,8 +68,8 @@ public class Searcher : ISearcher
|
||||
}
|
||||
else
|
||||
{
|
||||
dataLen = MemoryMarshal.Read<ushort>(buffer.Span[8..]);
|
||||
dataPtr = MemoryMarshal.Read<uint>(buffer.Span[10..]);
|
||||
dataLen = MemoryMarshal.Read<ushort>(buffer.Span.Slice(8));
|
||||
dataPtr = MemoryMarshal.Read<uint>(buffer.Span.Slice(10));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -80,6 +80,6 @@ public class Searcher : ISearcher
|
||||
}
|
||||
|
||||
var regionBuff = _cacheStrategy.GetData((int)dataPtr,dataLen);
|
||||
return Encoding.UTF8.GetString(regionBuff.Span);
|
||||
return Encoding.UTF8.GetString(regionBuff.Span.ToArray());
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user