Compare commits
7 Commits
Author | SHA1 | Date |
---|---|---|
Harald Wolff | 5ba98b1611 | |
Harald Wolff | b6a965eec8 | |
Harald Wolff | d01126396c | |
Harald Wolff | 00d2fdec51 | |
Harald Wolff | 2c25cc6385 | |
Harald Wolff | 5ed8193971 | |
Harald Wolff | db015ed6db |
2
build.ln
2
build.ln
|
@ -3,7 +3,7 @@
|
||||||
"dotnet"
|
"dotnet"
|
||||||
],
|
],
|
||||||
"env": {
|
"env": {
|
||||||
"NUGET_SOURCE": "https://nexus.niclas-thobaben.de/repository/l--n.de/",
|
"NUGET_SOURCE": "https://nexus.l--n.de/repository/ln.net/",
|
||||||
"CONFIGURATION": "Release"
|
"CONFIGURATION": "Release"
|
||||||
},
|
},
|
||||||
"stages": [
|
"stages": [
|
||||||
|
|
|
@ -36,8 +36,14 @@ namespace ln.type
|
||||||
targetValue = value;
|
targetValue = value;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (targetType.Equals(typeof(byte[])) && value is string svalue)
|
||||||
|
{
|
||||||
|
targetValue = Convert.FromBase64String(svalue);
|
||||||
|
} else if (targetType.Equals(typeof(string)) && (value is byte[] bytes))
|
||||||
|
{
|
||||||
|
targetValue = Convert.ToBase64String(bytes);
|
||||||
|
} else if (
|
||||||
!Implicit(value, targetType, out targetValue) &&
|
!Implicit(value, targetType, out targetValue) &&
|
||||||
!Implicit(value, value.GetType(), targetType, out targetValue) &&
|
!Implicit(value, value.GetType(), targetType, out targetValue) &&
|
||||||
!Explicit(value, targetType, out targetValue) &&
|
!Explicit(value, targetType, out targetValue) &&
|
||||||
|
|
|
@ -209,6 +209,28 @@ namespace ln.type
|
||||||
return BitConverter.ToDouble(bytes, 0);
|
return BitConverter.ToDouble(bytes, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string ReadCString(this Stream stream)
|
||||||
|
{
|
||||||
|
byte[] buffer = new byte[1024];
|
||||||
|
int p = 0, ch;
|
||||||
|
while ((ch = stream.ReadByte()) != -1)
|
||||||
|
{
|
||||||
|
if (ch == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (p == buffer.Length)
|
||||||
|
{
|
||||||
|
byte[] nb = new byte[buffer.Length << 1];
|
||||||
|
Array.Copy(buffer, nb, buffer.Length);
|
||||||
|
buffer = nb;
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer[p++] = (byte)ch;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Encoding.UTF8.GetString(buffer, 0, p);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
|
||||||
|
namespace ln.type
|
||||||
|
{
|
||||||
|
public class IPv4
|
||||||
|
{
|
||||||
|
public static readonly IPv4 ANY = new IPv4();
|
||||||
|
|
||||||
|
private UInt32 _ip;
|
||||||
|
private IPv4()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
public IPv4(UInt32 ip)
|
||||||
|
{
|
||||||
|
_ip = ip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IPv4(byte[] ipbytes)
|
||||||
|
{
|
||||||
|
_ip = BitConverter.ToUInt32(ipbytes, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] ToBytes => BitConverter.GetBytes(_ip);
|
||||||
|
|
||||||
|
public override bool Equals(Object obj) => (obj is IPv4 other) && _ip == other._ip;
|
||||||
|
public override int GetHashCode() => (int)_ip;
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
byte[] ipbytes = ToBytes;
|
||||||
|
return string.Format("{0}.{1}.{2}.{3}", ipbytes[3], ipbytes[2], ipbytes[1], ipbytes[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IPv4 operator ++(IPv4 ip) => new IPv4(ip._ip + 1);
|
||||||
|
public static IPv4 operator --(IPv4 ip) => new IPv4(ip._ip - 1);
|
||||||
|
|
||||||
|
public static IPv4 operator +(IPv4 ip, int n) => new IPv4((uint)(ip._ip + n));
|
||||||
|
public static IPv4 operator -(IPv4 ip, int n) => new IPv4((uint)(ip._ip - n));
|
||||||
|
|
||||||
|
public static implicit operator IPAddress(IPv4 ipv4) => new IPAddress(ipv4.ToBytes);
|
||||||
|
public static implicit operator IPv4(IPAddress ipAddress) => new IPv4(ipAddress.GetAddressBytes());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,11 +3,12 @@
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<Version>0.1.7</Version>
|
<Version>0.1.9</Version>
|
||||||
<Authors>Harald Wolff-Thobaben</Authors>
|
<Authors>Harald Wolff-Thobaben</Authors>
|
||||||
<Company>l--n.de</Company>
|
<Company>l--n.de</Company>
|
||||||
<AssemblyVersion>0.0.1.0</AssemblyVersion>
|
<AssemblyVersion>0.0.1.0</AssemblyVersion>
|
||||||
<FileVersion>0.0.1.0</FileVersion>
|
<FileVersion>0.0.1.0</FileVersion>
|
||||||
|
<PackageVersion>0.1.10-preview0</PackageVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
Loading…
Reference in New Issue