Compare commits
3 Commits
Author | SHA1 | Date |
---|---|---|
Niclas Thobaben | 3dd5823761 | |
Niclas Thobaben | 443be486ae | |
Niclas Thobaben | 4059809c15 |
|
@ -39,4 +39,3 @@ Thumbs.db
|
||||||
|
|
||||||
# dotCover
|
# dotCover
|
||||||
*.dotCover
|
*.dotCover
|
||||||
.build
|
|
||||||
|
|
|
@ -62,22 +62,6 @@ namespace ln.type
|
||||||
}
|
}
|
||||||
public static uint GetUInt(this byte[] bytes, ref int offset, Endianess endianess) => BitConverter.ToUInt32(bytes.Slice(ref offset, 4).To(endianess), 0);
|
public static uint GetUInt(this byte[] bytes, ref int offset, Endianess endianess) => BitConverter.ToUInt32(bytes.Slice(ref offset, 4).To(endianess), 0);
|
||||||
|
|
||||||
public static byte[] GetSingle(this byte[] bytes, ref int offset, out float value) => GetSingle(bytes, ref offset, out value, Endianess.LITTLE);
|
|
||||||
public static byte[] GetSingle(this byte[] bytes, ref int offset, out float value, Endianess endianess)
|
|
||||||
{
|
|
||||||
value = GetSingle(bytes, ref offset, endianess);
|
|
||||||
return bytes;
|
|
||||||
}
|
|
||||||
public static float GetSingle(this byte[] bytes, ref int offset, Endianess endianess) => BitConverter.ToSingle(bytes.Slice(ref offset, 4).To(endianess), 0);
|
|
||||||
|
|
||||||
public static byte[] GetDouble(this byte[] bytes, ref int offset, out double value) => GetDouble(bytes, ref offset, out value, Endianess.LITTLE);
|
|
||||||
public static byte[] GetDouble(this byte[] bytes, ref int offset, out double value, Endianess endianess)
|
|
||||||
{
|
|
||||||
value = GetDouble(bytes, ref offset, endianess);
|
|
||||||
return bytes;
|
|
||||||
}
|
|
||||||
public static double GetDouble(this byte[] bytes, ref int offset, Endianess endianess) => BitConverter.ToDouble(bytes.Slice(ref offset, 8).To(endianess), 0);
|
|
||||||
|
|
||||||
|
|
||||||
public static byte[] GetBytes(this byte[] bytes,ref int offset,int length,out byte[] value)
|
public static byte[] GetBytes(this byte[] bytes,ref int offset,int length,out byte[] value)
|
||||||
{
|
{
|
|
@ -11,9 +11,6 @@ using System;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Net.Http.Headers;
|
|
||||||
using System.ComponentModel;
|
|
||||||
|
|
||||||
namespace ln.type
|
namespace ln.type
|
||||||
{
|
{
|
||||||
public static class Cast
|
public static class Cast
|
||||||
|
@ -21,40 +18,26 @@ namespace ln.type
|
||||||
public static T To<T>(object value) => (T)To(value, typeof(T));
|
public static T To<T>(object value) => (T)To(value, typeof(T));
|
||||||
public static object To(object value, Type targetType)
|
public static object To(object value, Type targetType)
|
||||||
{
|
{
|
||||||
if (!To(value, targetType, out object targetValue))
|
|
||||||
throw new NotSupportedException();
|
|
||||||
return targetValue;
|
|
||||||
}
|
|
||||||
public static bool To(object value, Type targetType, out object targetValue)
|
|
||||||
{
|
|
||||||
targetValue = null;
|
|
||||||
if (Object.ReferenceEquals(null, value))
|
if (Object.ReferenceEquals(null, value))
|
||||||
return true;
|
return null;
|
||||||
|
|
||||||
if (targetType.IsInstanceOfType(value))
|
if (targetType.IsInstanceOfType(value))
|
||||||
{
|
return value;
|
||||||
targetValue = value;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (targetType.Equals(typeof(byte[])) && value is string svalue)
|
object casted;
|
||||||
{
|
|
||||||
targetValue = Convert.FromBase64String(svalue);
|
if (
|
||||||
} else if (targetType.Equals(typeof(string)) && (value is byte[] bytes))
|
!Implicit(value, targetType, out casted) &&
|
||||||
{
|
!Implicit(value, value.GetType(), targetType, out casted) &&
|
||||||
targetValue = Convert.ToBase64String(bytes);
|
!Explicit(value, targetType, out casted) &&
|
||||||
} else if (
|
!Explicit(value, value.GetType(), targetType, out casted)
|
||||||
!Implicit(value, targetType, out targetValue) &&
|
|
||||||
!Implicit(value, value.GetType(), targetType, out targetValue) &&
|
|
||||||
!Explicit(value, targetType, out targetValue) &&
|
|
||||||
!Explicit(value, value.GetType(), targetType, out targetValue)
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (targetType.IsEnum)
|
if (targetType.IsEnum)
|
||||||
{
|
{
|
||||||
if (value is string sValue)
|
if (value is string sValue)
|
||||||
{
|
{
|
||||||
targetValue = Enum.Parse(targetType, sValue);
|
casted = Enum.Parse(targetType, sValue);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
|
@ -66,25 +49,16 @@ namespace ln.type
|
||||||
Array castedArray = Array.CreateInstance(targetType.GetElementType(), array.Length);
|
Array castedArray = Array.CreateInstance(targetType.GetElementType(), array.Length);
|
||||||
|
|
||||||
for (int n = 0; n < array.Length; n++)
|
for (int n = 0; n < array.Length; n++)
|
||||||
{
|
castedArray.SetValue(To(array.GetValue(n), targetType.GetElementType()), n);
|
||||||
if (!To(array.GetValue(n), targetType.GetElementType(), out object el))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
castedArray.SetValue(el, n);
|
casted = castedArray;
|
||||||
}
|
|
||||||
|
|
||||||
targetValue = castedArray;
|
|
||||||
}
|
|
||||||
else if ((value is string text) && (TypeDescriptor.GetConverter(targetType).CanConvertFrom(typeof(string))))
|
|
||||||
{
|
|
||||||
targetValue = TypeDescriptor.GetConverter(targetType).ConvertFromInvariantString(value as string);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
targetValue = Convert.ChangeType(value, targetType);
|
casted = Convert.ChangeType(value, targetType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return casted;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool Implicit(object value, Type type, out object casted) => Implicit(value, type, type, out casted);
|
public static bool Implicit(object value, Type type, out object casted) => Implicit(value, type, type, out casted);
|
|
@ -209,28 +209,6 @@ 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,28 @@
|
||||||
|
pipeline {
|
||||||
|
agent any
|
||||||
|
stages {
|
||||||
|
stage('Integration-Tests') {
|
||||||
|
steps {
|
||||||
|
sh 'echo "Start Integration-Tests..."'
|
||||||
|
sh 'echo "TODO To be implemented!"'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Install') {
|
||||||
|
steps {
|
||||||
|
sh 'echo "Start Install..."'
|
||||||
|
sh 'dotnet build'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('deploy') {
|
||||||
|
parallel {
|
||||||
|
stage('deploy-RELEASE') {
|
||||||
|
steps {
|
||||||
|
sh 'echo "Deploy release..."'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,7 +8,6 @@
|
||||||
// *
|
// *
|
||||||
// **/
|
// **/
|
||||||
using System;
|
using System;
|
||||||
using System.Reflection.Metadata;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
namespace ln.type
|
namespace ln.type
|
||||||
{
|
{
|
||||||
|
@ -44,20 +43,6 @@ namespace ln.type
|
||||||
Parse(String.Format("{0}://{1}{2}", scheme, authority, path));
|
Parse(String.Format("{0}://{1}{2}", scheme, authority, path));
|
||||||
ParseAuthority();
|
ParseAuthority();
|
||||||
}
|
}
|
||||||
public URI(String scheme,string[] userinfo,string host,string port,string path,string query,string fragment)
|
|
||||||
{
|
|
||||||
Scheme = scheme;
|
|
||||||
UserInfo = userinfo ?? new string[0];
|
|
||||||
Host = host;
|
|
||||||
Port = port;
|
|
||||||
if (userinfo.Length == 0)
|
|
||||||
Authority = String.Format("{0}:{1}", Host, Port);
|
|
||||||
else
|
|
||||||
Authority = String.Format("{2}@{0}:{1}", Host, Port, string.Join(':', UserInfo));
|
|
||||||
Path = path;
|
|
||||||
Query = query;
|
|
||||||
Fragment = fragment;
|
|
||||||
}
|
|
||||||
public URI(String scheme,String authority,string path,string query,string fragment)
|
public URI(String scheme,String authority,string path,string query,string fragment)
|
||||||
{
|
{
|
||||||
Scheme = scheme;
|
Scheme = scheme;
|
||||||
|
@ -90,13 +75,6 @@ namespace ln.type
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public URI WithUserInfo(params string[] userInfo) => new URI(Scheme,userInfo, Host, Port, Path, Query, Fragment);
|
|
||||||
public URI WithHost(string host) => new URI(Scheme,UserInfo, host, Port, Path, Query, Fragment);
|
|
||||||
public URI WithPort(string port) => new URI(Scheme,UserInfo, Host, port, Path, Query, Fragment);
|
|
||||||
public URI WithScheme(string scheme) => new URI(scheme, UserInfo, Host, Port, Path, Query, Fragment);
|
|
||||||
public URI WithPath(string path) => new URI(Scheme, UserInfo, Host, Port, path, Query, Fragment);
|
|
||||||
public URI WithQuery(string query) => new URI(Scheme, UserInfo, Host, Port, Path, query, Fragment);
|
|
||||||
public URI WithFragment(string fragment) => new URI(Scheme, UserInfo, Host, Port, Path, Query, fragment);
|
|
||||||
|
|
||||||
private void Parse(String uri)
|
private void Parse(String uri)
|
||||||
{
|
{
|
||||||
|
@ -203,8 +181,7 @@ namespace ln.type
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public override string ToString() => ToString(false);
|
public override string ToString()
|
||||||
public string ToString(bool withFullUserInfo)
|
|
||||||
{
|
{
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
|
||||||
|
@ -216,10 +193,7 @@ namespace ln.type
|
||||||
stringBuilder.Append("//");
|
stringBuilder.Append("//");
|
||||||
if (UserInfo.Length > 0)
|
if (UserInfo.Length > 0)
|
||||||
{
|
{
|
||||||
if (withFullUserInfo)
|
stringBuilder.Append(UserInfo[0]);
|
||||||
stringBuilder.Append(String.Join(':',UserInfo));
|
|
||||||
else
|
|
||||||
stringBuilder.Append(UserInfo[0]);
|
|
||||||
stringBuilder.Append('@');
|
stringBuilder.Append('@');
|
||||||
}
|
}
|
||||||
|
|
17
build.ln
17
build.ln
|
@ -1,17 +0,0 @@
|
||||||
{
|
|
||||||
"templates": [
|
|
||||||
"dotnet"
|
|
||||||
],
|
|
||||||
"env": {
|
|
||||||
"NUGET_SOURCE": "https://nexus.l--n.de/repository/ln.net/",
|
|
||||||
"CONFIGURATION": "Release"
|
|
||||||
},
|
|
||||||
"stages": [
|
|
||||||
{
|
|
||||||
"name": "prepare",
|
|
||||||
"commands": [
|
|
||||||
"dotnet prepare */*.csproj"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -3,12 +3,11 @@
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<Version>0.1.9</Version>
|
<Version>0.1.0</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>
|
48
ln.type.sln
48
ln.type.sln
|
@ -1,48 +0,0 @@
|
||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
|
||||||
# Visual Studio 15
|
|
||||||
VisualStudioVersion = 15.0.26124.0
|
|
||||||
MinimumVisualStudioVersion = 15.0.26124.0
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ln.type", "ln.type\ln.type.csproj", "{98686C62-A822-4045-8403-A6CBD40E7EB3}"
|
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ln.type.tests", "ln.type.tests\ln.type.tests.csproj", "{EDFCB172-4EFD-4731-98CB-CB0E082F3204}"
|
|
||||||
EndProject
|
|
||||||
Global
|
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
||||||
Debug|Any CPU = Debug|Any CPU
|
|
||||||
Debug|x64 = Debug|x64
|
|
||||||
Debug|x86 = Debug|x86
|
|
||||||
Release|Any CPU = Release|Any CPU
|
|
||||||
Release|x64 = Release|x64
|
|
||||||
Release|x86 = Release|x86
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
|
||||||
HideSolutionNode = FALSE
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
|
||||||
{98686C62-A822-4045-8403-A6CBD40E7EB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{98686C62-A822-4045-8403-A6CBD40E7EB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{98686C62-A822-4045-8403-A6CBD40E7EB3}.Debug|x64.ActiveCfg = Debug|Any CPU
|
|
||||||
{98686C62-A822-4045-8403-A6CBD40E7EB3}.Debug|x64.Build.0 = Debug|Any CPU
|
|
||||||
{98686C62-A822-4045-8403-A6CBD40E7EB3}.Debug|x86.ActiveCfg = Debug|Any CPU
|
|
||||||
{98686C62-A822-4045-8403-A6CBD40E7EB3}.Debug|x86.Build.0 = Debug|Any CPU
|
|
||||||
{98686C62-A822-4045-8403-A6CBD40E7EB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{98686C62-A822-4045-8403-A6CBD40E7EB3}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{98686C62-A822-4045-8403-A6CBD40E7EB3}.Release|x64.ActiveCfg = Release|Any CPU
|
|
||||||
{98686C62-A822-4045-8403-A6CBD40E7EB3}.Release|x64.Build.0 = Release|Any CPU
|
|
||||||
{98686C62-A822-4045-8403-A6CBD40E7EB3}.Release|x86.ActiveCfg = Release|Any CPU
|
|
||||||
{98686C62-A822-4045-8403-A6CBD40E7EB3}.Release|x86.Build.0 = Release|Any CPU
|
|
||||||
{EDFCB172-4EFD-4731-98CB-CB0E082F3204}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{EDFCB172-4EFD-4731-98CB-CB0E082F3204}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{EDFCB172-4EFD-4731-98CB-CB0E082F3204}.Debug|x64.ActiveCfg = Debug|Any CPU
|
|
||||||
{EDFCB172-4EFD-4731-98CB-CB0E082F3204}.Debug|x64.Build.0 = Debug|Any CPU
|
|
||||||
{EDFCB172-4EFD-4731-98CB-CB0E082F3204}.Debug|x86.ActiveCfg = Debug|Any CPU
|
|
||||||
{EDFCB172-4EFD-4731-98CB-CB0E082F3204}.Debug|x86.Build.0 = Debug|Any CPU
|
|
||||||
{EDFCB172-4EFD-4731-98CB-CB0E082F3204}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{EDFCB172-4EFD-4731-98CB-CB0E082F3204}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{EDFCB172-4EFD-4731-98CB-CB0E082F3204}.Release|x64.ActiveCfg = Release|Any CPU
|
|
||||||
{EDFCB172-4EFD-4731-98CB-CB0E082F3204}.Release|x64.Build.0 = Release|Any CPU
|
|
||||||
{EDFCB172-4EFD-4731-98CB-CB0E082F3204}.Release|x86.ActiveCfg = Release|Any CPU
|
|
||||||
{EDFCB172-4EFD-4731-98CB-CB0E082F3204}.Release|x86.Build.0 = Release|Any CPU
|
|
||||||
EndGlobalSection
|
|
||||||
EndGlobal
|
|
|
@ -1,41 +0,0 @@
|
||||||
using NUnit.Framework;
|
|
||||||
|
|
||||||
namespace ln.type.tests
|
|
||||||
{
|
|
||||||
public class URITests
|
|
||||||
{
|
|
||||||
[SetUp]
|
|
||||||
public void Setup()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void Test1()
|
|
||||||
{
|
|
||||||
string testBaseURI = "http://alpha:beta:gamma@myHost:3456/path/to/resource?query=all#fragmentA";
|
|
||||||
|
|
||||||
URI testURI = new URI(testBaseURI);
|
|
||||||
Assert.AreEqual(testBaseURI, testURI.ToString(true));
|
|
||||||
|
|
||||||
Assert.AreEqual(
|
|
||||||
"http://omega@myHost:3456/path/to/resource?query=all#fragmentA",
|
|
||||||
testURI.WithUserInfo("omega").ToString(true)
|
|
||||||
);
|
|
||||||
Assert.AreEqual(
|
|
||||||
"http://alpha:beta:gamma@myHost:3456/my/path?query=all#fragmentA",
|
|
||||||
testURI.WithPath("/my/path").ToString(true)
|
|
||||||
);
|
|
||||||
Assert.AreEqual(
|
|
||||||
"http://alpha:beta:gamma@myHost:3456/path/to/resource?such=a&shame#fragmentA",
|
|
||||||
testURI.WithQuery("such=a&shame").ToString(true)
|
|
||||||
);
|
|
||||||
Assert.AreEqual(
|
|
||||||
"https://alpha:beta:gamma@myHost:3456/path/to/resource?query=all#fragmentA",
|
|
||||||
testURI.WithScheme("https").ToString(true)
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
Assert.Pass();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
|
||||||
|
|
||||||
<IsPackable>false</IsPackable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
|
||||||
<PackageReference Include="NUnit3TestAdapter" Version="3.16.1" />
|
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0"/>
|
|
||||||
<ProjectReference Include="../ln.type/ln.type.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
|
@ -1,45 +0,0 @@
|
||||||
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());
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue