diff --git a/nant/release.build b/nant/release.build index 6c224d3..b9dfcd5 100644 --- a/nant/release.build +++ b/nant/release.build @@ -4,7 +4,7 @@ - + @@ -14,7 +14,10 @@ - + + + + @@ -115,8 +118,26 @@ - - + + + + + + + + + + + + + + + + + + + + diff --git a/release/IPNetwork-2.1.1.zip b/release/IPNetwork-2.1.1.zip new file mode 100644 index 0000000..ea1fb23 Binary files /dev/null and b/release/IPNetwork-2.1.1.zip differ diff --git a/release/IPNetwork2.2.1.1.nupkg b/release/IPNetwork2.2.1.1.nupkg new file mode 100644 index 0000000..2e41d66 Binary files /dev/null and b/release/IPNetwork2.2.1.1.nupkg differ diff --git a/src/System.Net.IPNetwork.snk b/src/System.Net.IPNetwork.snk new file mode 100644 index 0000000..1b97c6f Binary files /dev/null and b/src/System.Net.IPNetwork.snk differ diff --git a/src/System.Net.IPNetwork/BigIntegerExt.cs b/src/System.Net.IPNetwork/BigIntegerExt.cs index 87e31f0..8b19708 100644 --- a/src/System.Net.IPNetwork/BigIntegerExt.cs +++ b/src/System.Net.IPNetwork/BigIntegerExt.cs @@ -1,153 +1,153 @@ -using System.Collections.Generic; - +using System.Collections.Generic; + namespace System.Net -{ - using System; - using System.Numerics; - using System.Text; - - /// - /// Extension methods to convert - /// instances to hexadecimal, octal, and binary strings. - /// - public static class BigIntegerExtensions { - /// - /// Converts a to a binary string. - /// - /// A . - /// - /// A containing a binary - /// representation of the supplied . - /// - public static string ToBinaryString(this BigInteger bigint) { - var bytes = bigint.ToByteArray(); - var idx = bytes.Length - 1; - - // Create a StringBuilder having appropriate capacity. - var base2 = new StringBuilder(bytes.Length * 8); - - // Convert first byte to binary. - var binary = Convert.ToString(bytes[idx], 2); - - // Ensure leading zero exists if value is positive. - if (binary[0] != '0' && bigint.Sign == 1) { - base2.Append('0'); - } - - // Append binary string to StringBuilder. - base2.Append(binary); - - // Convert remaining bytes adding leading zeros. - for (idx--; idx >= 0; idx--) { - base2.Append(Convert.ToString(bytes[idx], 2).PadLeft(8, '0')); - } - - return base2.ToString(); - } - - /// - /// Converts a to a hexadecimal string. - /// - /// A . - /// - /// A containing a hexadecimal - /// representation of the supplied . - /// - public static string ToHexadecimalString(this BigInteger bigint) { - return bigint.ToString("X"); - } - - /// - /// Converts a to a octal string. - /// - /// A . - /// - /// A containing an octal - /// representation of the supplied . - /// - public static string ToOctalString(this BigInteger bigint) { - var bytes = bigint.ToByteArray(); - var idx = bytes.Length - 1; - - // Create a StringBuilder having appropriate capacity. - var base8 = new StringBuilder(((bytes.Length / 3) + 1) * 8); - - // Calculate how many bytes are extra when byte array is split - // into three-byte (24-bit) chunks. - var extra = bytes.Length % 3; - - // If no bytes are extra, use three bytes for first chunk. - if (extra == 0) { - extra = 3; - } - - // Convert first chunk (24-bits) to integer value. - int int24 = 0; - for (; extra != 0; extra--) { - int24 <<= 8; - int24 += bytes[idx--]; - } - - // Convert 24-bit integer to octal without adding leading zeros. - var octal = Convert.ToString(int24, 8); - - // Ensure leading zero exists if value is positive. - if (octal[0] != '0' && bigint.Sign == 1) { - base8.Append('0'); - } - - // Append first converted chunk to StringBuilder. - base8.Append(octal); - - // Convert remaining 24-bit chunks, adding leading zeros. - for (; idx >= 0; idx -= 3) { - int24 = (bytes[idx] << 16) + (bytes[idx - 1] << 8) + bytes[idx - 2]; - base8.Append(Convert.ToString(int24, 8).PadLeft(8, '0')); - } - - return base8.ToString(); - } - - /// - /// - /// Reverse a Positive BigInteger ONLY - /// Bitwise ~ operator - /// - /// Input : FF FF FF FF - /// Width : 4 - /// Result : 00 00 00 00 - /// - /// - /// Input : 00 00 00 00 - /// Width : 4 - /// Result : FF FF FF FF - /// - /// Input : FF FF FF FF - /// Width : 8 - /// Result : FF FF FF FF 00 00 00 00 - /// - /// - /// Input : 00 00 00 00 - /// Width : 8 - /// Result : FF FF FF FF FF FF FF FF - /// - /// - /// - /// - /// - public static BigInteger PositiveReverse(this BigInteger input, int width) { - - var result = new List(); - var bytes = input.ToByteArray(); - var work = new byte[width]; - Array.Copy(bytes, 0, work, 0, bytes.Length - 1); // Length -1 : positive BigInteger - - for (int i = 0; i < work.Length; i++) { - result.Add((byte)(~work[i])); - } - result.Add(0); // positive BigInteger - return new BigInteger(result.ToArray()); - - } - } -} +{ + using System; + using System.Numerics; + using System.Text; + + /// + /// Extension methods to convert + /// instances to hexadecimal, octal, and binary strings. + /// + public static class BigIntegerExtensions { + /// + /// Converts a to a binary string. + /// + /// A . + /// + /// A containing a binary + /// representation of the supplied . + /// + public static string ToBinaryString(this BigInteger bigint) { + var bytes = bigint.ToByteArray(); + var idx = bytes.Length - 1; + + // Create a StringBuilder having appropriate capacity. + var base2 = new StringBuilder(bytes.Length * 8); + + // Convert first byte to binary. + var binary = Convert.ToString(bytes[idx], 2); + + // Ensure leading zero exists if value is positive. + if (binary[0] != '0' && bigint.Sign == 1) { + base2.Append('0'); + } + + // Append binary string to StringBuilder. + base2.Append(binary); + + // Convert remaining bytes adding leading zeros. + for (idx--; idx >= 0; idx--) { + base2.Append(Convert.ToString(bytes[idx], 2).PadLeft(8, '0')); + } + + return base2.ToString(); + } + + /// + /// Converts a to a hexadecimal string. + /// + /// A . + /// + /// A containing a hexadecimal + /// representation of the supplied . + /// + public static string ToHexadecimalString(this BigInteger bigint) { + return bigint.ToString("X"); + } + + /// + /// Converts a to a octal string. + /// + /// A . + /// + /// A containing an octal + /// representation of the supplied . + /// + public static string ToOctalString(this BigInteger bigint) { + var bytes = bigint.ToByteArray(); + var idx = bytes.Length - 1; + + // Create a StringBuilder having appropriate capacity. + var base8 = new StringBuilder(((bytes.Length / 3) + 1) * 8); + + // Calculate how many bytes are extra when byte array is split + // into three-byte (24-bit) chunks. + var extra = bytes.Length % 3; + + // If no bytes are extra, use three bytes for first chunk. + if (extra == 0) { + extra = 3; + } + + // Convert first chunk (24-bits) to integer value. + int int24 = 0; + for (; extra != 0; extra--) { + int24 <<= 8; + int24 += bytes[idx--]; + } + + // Convert 24-bit integer to octal without adding leading zeros. + var octal = Convert.ToString(int24, 8); + + // Ensure leading zero exists if value is positive. + if (octal[0] != '0' && bigint.Sign == 1) { + base8.Append('0'); + } + + // Append first converted chunk to StringBuilder. + base8.Append(octal); + + // Convert remaining 24-bit chunks, adding leading zeros. + for (; idx >= 0; idx -= 3) { + int24 = (bytes[idx] << 16) + (bytes[idx - 1] << 8) + bytes[idx - 2]; + base8.Append(Convert.ToString(int24, 8).PadLeft(8, '0')); + } + + return base8.ToString(); + } + + /// + /// + /// Reverse a Positive BigInteger ONLY + /// Bitwise ~ operator + /// + /// Input : FF FF FF FF + /// Width : 4 + /// Result : 00 00 00 00 + /// + /// + /// Input : 00 00 00 00 + /// Width : 4 + /// Result : FF FF FF FF + /// + /// Input : FF FF FF FF + /// Width : 8 + /// Result : FF FF FF FF 00 00 00 00 + /// + /// + /// Input : 00 00 00 00 + /// Width : 8 + /// Result : FF FF FF FF FF FF FF FF + /// + /// + /// + /// + /// + public static BigInteger PositiveReverse(this BigInteger input, int width) { + + var result = new List(); + var bytes = input.ToByteArray(); + var work = new byte[width]; + Array.Copy(bytes, 0, work, 0, bytes.Length - 1); // Length -1 : positive BigInteger + + for (int i = 0; i < work.Length; i++) { + result.Add((byte)(~work[i])); + } + result.Add(0); // positive BigInteger + return new BigInteger(result.ToArray()); + + } + } +} diff --git a/src/System.Net.IPNetwork/Properties/AssemblyInfo.cs b/src/System.Net.IPNetwork/Properties/AssemblyInfo.cs index 83e11f7..89448c6 100644 --- a/src/System.Net.IPNetwork/Properties/AssemblyInfo.cs +++ b/src/System.Net.IPNetwork/Properties/AssemblyInfo.cs @@ -6,7 +6,7 @@ // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("System.Net.IPNetwork")] -[assembly: AssemblyDescription("")] +[assembly: AssemblyDescription("IPNetwork C# library take care of complex network, ip, ipv4, ipv6, netmask, cidr, subnet, subnetting, supernet and supernetting calculation for .Net developpers. It works with IPv4 and IPv6 as well. It is written in C# for .NetStandard and coreclr and has a light and clean API and is fully unit tested.")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Luc Dvchosal")] [assembly: AssemblyProduct("System.Net.IPNetwork")] @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.1.0.0")] +[assembly: AssemblyVersion("2.1.1.0")] [assembly: AssemblyFileVersion("2.1.0.0")] diff --git a/src/System.Net.IPNetwork/System.Net.IPNetwork.csproj b/src/System.Net.IPNetwork/System.Net.IPNetwork.csproj index ac374a4..4f7be0d 100644 --- a/src/System.Net.IPNetwork/System.Net.IPNetwork.csproj +++ b/src/System.Net.IPNetwork/System.Net.IPNetwork.csproj @@ -1,23 +1,40 @@  - netstandard1.3 + netstandard1.3;net40;net45;net46 IPNetwork2 - 2.1.0 + 2.1.1 false https://github.com/lduchosal/ipnetwork/blob/master/LICENSE https://github.com/lduchosal/ipnetwork false - dotnetstandard1.3 support + dotnetstandard1.3 support +dotnet46 support +dotnet45 support +dotnet40 support +signed dlls ipnetwork network ip ipv4 ipv6 netmask cidr subnet subnetting supernet supernetting calculation IPNetwork utility classes for .Net IPNetwork C# library take care of complex network, ip, ipv4, ipv6, netmask, cidr, subnet, subnetting, supernet and supernetting calculation for .Net developpers. It works with IPv4 and IPv6 as well. It is written in C# for .NetStandard and coreclr and has a light and clean API and is fully unit tested. - IPNetwork utility classes for .Net - IPNetwork utility classes take care of complex network, IP, IPv4, IPv6, netmask, CIDR, subnet, subnetting, supernet, and supernetting calculation for .NET developers. It works with IPv4 as well as IPv6, is written in C#, has a light and clean API, and is fully unit-tested. + IPNetwork utility classes for .Net Luc Dvchosal Luc Dvchosal Copyright 2017 + True + System.Net.IPNetwork.snk + https://github.com/lduchosal/ipnetwork.git + git + + + + + + + + + \ No newline at end of file diff --git a/src/System.Net.IPNetwork/System.Net.IPNetwork.snk b/src/System.Net.IPNetwork/System.Net.IPNetwork.snk new file mode 100644 index 0000000..1b97c6f Binary files /dev/null and b/src/System.Net.IPNetwork/System.Net.IPNetwork.snk differ diff --git a/src/ipnetwork.sln b/src/ipnetwork.sln index 44835da..c0ae0de 100644 --- a/src/ipnetwork.sln +++ b/src/ipnetwork.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26228.4 +VisualStudioVersion = 15.0.26403.7 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Net.IPNetwork", "System.Net.IPNetwork\System.Net.IPNetwork.csproj", "{D4F7FF33-1DD1-4DE8-B1B1-D01B89C7D11F}" EndProject