2023-03-21 12:20:21 +00:00
|
|
|
|
namespace CodexDistTestCore
|
2023-03-21 08:20:09 +00:00
|
|
|
|
{
|
|
|
|
|
public class ByteSize
|
|
|
|
|
{
|
|
|
|
|
public ByteSize(long sizeInBytes)
|
|
|
|
|
{
|
|
|
|
|
SizeInBytes = sizeInBytes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public long SizeInBytes { get; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class IntExtensions
|
|
|
|
|
{
|
|
|
|
|
private const long Kilo = 1024;
|
|
|
|
|
|
|
|
|
|
public static ByteSize KB(this long i)
|
|
|
|
|
{
|
|
|
|
|
return new ByteSize(i * Kilo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static ByteSize MB(this long i)
|
|
|
|
|
{
|
2023-03-21 12:20:21 +00:00
|
|
|
|
return (i * Kilo).KB();
|
2023-03-21 08:20:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static ByteSize GB(this long i)
|
|
|
|
|
{
|
2023-03-21 12:20:21 +00:00
|
|
|
|
return (i * Kilo).MB();
|
2023-03-21 08:20:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static ByteSize TB(this long i)
|
|
|
|
|
{
|
2023-03-21 12:20:21 +00:00
|
|
|
|
return (i * Kilo).GB();
|
2023-03-21 08:20:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static ByteSize KB(this int i)
|
|
|
|
|
{
|
2023-03-21 12:20:21 +00:00
|
|
|
|
return Convert.ToInt64(i).KB();
|
2023-03-21 08:20:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static ByteSize MB(this int i)
|
|
|
|
|
{
|
2023-03-21 12:20:21 +00:00
|
|
|
|
return Convert.ToInt64(i).MB();
|
2023-03-21 08:20:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static ByteSize GB(this int i)
|
|
|
|
|
{
|
2023-03-21 12:20:21 +00:00
|
|
|
|
return Convert.ToInt64(i).GB();
|
2023-03-21 08:20:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static ByteSize TB(this int i)
|
|
|
|
|
{
|
2023-03-21 12:20:21 +00:00
|
|
|
|
return Convert.ToInt64(i).TB();
|
2023-03-21 08:20:09 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|