mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-10 03:45:41 +00:00
(#32) Add (short/int/long).To(Host/Network)Order
Implementation calls IPAddress.(Host/Network)To(Network/Host)Order
This commit is contained in:
parent
61c122c9ea
commit
6e4a9882e9
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
|
||||||
namespace X10D
|
namespace X10D
|
||||||
{
|
{
|
||||||
@ -180,5 +181,25 @@ namespace X10D
|
|||||||
{
|
{
|
||||||
return value != 0;
|
return value != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts an integer value from network byte order to host byte order.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value">The value to convert, expressed in network byte order.</param>
|
||||||
|
/// <returns>An integer value, expressed in host byte order.</returns>
|
||||||
|
public static short ToHostOrder(this short value)
|
||||||
|
{
|
||||||
|
return IPAddress.NetworkToHostOrder(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts an integer value from host byte order to network byte order.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value">The value to convert, expressed in host byte order.</param>
|
||||||
|
/// <returns>An integer value, expressed in network byte order.</returns>
|
||||||
|
public static short ToNetworkOrder(this short value)
|
||||||
|
{
|
||||||
|
return IPAddress.HostToNetworkOrder(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
|
||||||
namespace X10D
|
namespace X10D
|
||||||
{
|
{
|
||||||
@ -180,5 +181,25 @@ namespace X10D
|
|||||||
{
|
{
|
||||||
return value != 0;
|
return value != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts an integer value from network byte order to host byte order.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value">The value to convert, expressed in network byte order.</param>
|
||||||
|
/// <returns>An integer value, expressed in host byte order.</returns>
|
||||||
|
public static int ToHostOrder(this int value)
|
||||||
|
{
|
||||||
|
return IPAddress.NetworkToHostOrder(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts an integer value from host byte order to network byte order.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value">The value to convert, expressed in host byte order.</param>
|
||||||
|
/// <returns>An integer value, expressed in network byte order.</returns>
|
||||||
|
public static int ToNetworkOrder(this int value)
|
||||||
|
{
|
||||||
|
return IPAddress.HostToNetworkOrder(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
|
||||||
namespace X10D
|
namespace X10D
|
||||||
{
|
{
|
||||||
@ -206,5 +207,25 @@ namespace X10D
|
|||||||
{
|
{
|
||||||
return value != 0;
|
return value != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts an integer value from network byte order to host byte order.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value">The value to convert, expressed in network byte order.</param>
|
||||||
|
/// <returns>An integer value, expressed in host byte order.</returns>
|
||||||
|
public static long ToHostOrder(this long value)
|
||||||
|
{
|
||||||
|
return IPAddress.NetworkToHostOrder(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts an integer value from host byte order to network byte order.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value">The value to convert, expressed in host byte order.</param>
|
||||||
|
/// <returns>An integer value, expressed in network byte order.</returns>
|
||||||
|
public static long ToNetworkOrder(this long value)
|
||||||
|
{
|
||||||
|
return IPAddress.HostToNetworkOrder(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user