Humanizer.ByteRate
ByteRate Class
Class to hold a ByteSize and a measurement interval, for the purpose of calculating the rate of transfer
public class ByteRate : System.IComparable<Humanizer.ByteRate>, System.IEquatable<Humanizer.ByteRate>, System.IComparable
Inheritance System.Object → ByteRate
Implements System.IComparable<ByteRate>, System.IEquatable<ByteRate>, System.IComparable
Remarks
Create a ByteRate with given quantity of bytes across an interval
Constructors
ByteRate(ByteSize, TimeSpan) Constructor
Class to hold a ByteSize and a measurement interval, for the purpose of calculating the rate of transfer
public ByteRate(Humanizer.ByteSize size, System.TimeSpan interval);
Parameters
size ByteSize
interval System.TimeSpan
Remarks
Create a ByteRate with given quantity of bytes across an interval
Properties
ByteRate.Interval Property
Interval that bytes were transferred in
public System.TimeSpan Interval { get; }
Property Value
ByteRate.Size Property
Quantity of bytes
public Humanizer.ByteSize Size { get; }
Property Value
Methods
ByteRate.CompareTo(ByteRate) Method
Compares this rate with another rate after normalizing both to bytes per second.
public int CompareTo(Humanizer.ByteRate? other);
Parameters
other ByteRate
The rate to compare with.
Returns
ByteRate.CompareTo(object) Method
public int CompareTo(object? obj);
Parameters
obj System.Object
Implements CompareTo(object)
Returns
ByteRate.Equals(ByteRate) Method
public bool Equals(Humanizer.ByteRate? other);
Parameters
other ByteRate
Returns
ByteRate.Equals(object) Method
public override bool Equals(object? obj);
Parameters
obj System.Object
Returns
ByteRate.GetHashCode() Method
public override int GetHashCode();
Returns
ByteRate.Humanize(TimeUnit) Method
Calculate rate for the quantity of bytes and interval defined by this instance
public string Humanize(Humanizer.TimeUnit timeUnit=Humanizer.TimeUnit.Second);
Parameters
timeUnit TimeUnit
Unit of time to calculate rate for (defaults is per second)
Returns
ByteRate.Humanize(string, TimeUnit, CultureInfo) Method
Calculate rate for the quantity of bytes and interval defined by this instance
public string Humanize(string? format, Humanizer.TimeUnit timeUnit=Humanizer.TimeUnit.Second, System.Globalization.CultureInfo? culture=null);
Parameters
format System.String
The string format to use for the number of bytes
timeUnit TimeUnit
Unit of time to calculate rate for (defaults is per second)
culture System.Globalization.CultureInfo
Culture to use. If null, current thread's culture is used.
Returns
ByteRate.HumanizeWithUnitSystem(ByteSizeUnitSystem, string, TimeUnit, CultureInfo) Method
Calculates and humanizes this rate using an explicitly selected byte-size unit system.
public string HumanizeWithUnitSystem(Humanizer.ByteSizeUnitSystem unitSystem, string? format=null, Humanizer.TimeUnit timeUnit=Humanizer.TimeUnit.Second, System.Globalization.CultureInfo? culture=null);
Parameters
unitSystem ByteSizeUnitSystem
The byte-size unit system to use.
format System.String
The numeric format and optional byte-size unit token. For DecimalSi and
BinaryIec, SI/IEC-prefixed unit tokens are matched case-insensitively,
while b and B remain case-sensitive; output uses canonical symbol casing.
Legacy preserves established matching behavior.
timeUnit TimeUnit
The time unit to use for the displayed rate.
culture System.Globalization.CultureInfo
The culture used to format the numeric value, byte-size unit, and time-unit symbol.
Returns
System.String
The humanized rate.
Exceptions
System.ArgumentOutOfRangeException
unitSystem is not defined.
System.NotSupportedException
timeUnit is not Second, Minute,
or Hour.
System.FormatException
format is invalid, or selects a token not supported by the selected non-legacy system.
ByteRate.ToString() Method
Returns the humanized rate using the default format and time unit.
public override string ToString();