CGroupValue<T> Struct
Holds the value of a cgroup interface file together with the reason a value may be absent.
public readonly struct CGroupValue<T> : IEquatable<CGroupValue<T>>Type parameters
T- The type of the parsed value.
Remarks
A cgroup getter has four possible outcomes, and reporting them all as null makes them indistinguishable: a caller cannot tell "the memory controller is not enabled" from "memory is unlimited". CGroupValue<T>.State keeps them apart. The default value of this type is CGroupValueState.Unavailable.
- Implements
Properties
| Name | Description |
|---|---|
| IsConfigured | Gets a value indicating whether the interface file holds a value. |
| RawValue | Gets the content of the interface file with leading and trailing whitespace removed, or null when the file does not exist. |
| State | Gets what the interface file holds. |
| Value | Gets the value held by the interface file. |
IsConfigured
CGroupValue.csRawValue
CGroupValue.csState
CGroupValue.csValue
CGroupValue.csGets the value held by the interface file.
public T Value { get; }Property value
T
Exceptions
InvalidOperationException- The interface file does not hold a value. Use
CGroupValue<T>.StateorCGroupValue<T>.TryGetValueto handle that case.
Methods
| Name | Description |
|---|---|
| Equals(CGroupValue<T>) | Indicates whether the current object is equal to another object of the same type. |
| Equals(object?) | Indicates whether this instance and a specified object are equal. |
| GetHashCode() | Returns the hash code for this instance. |
| GetValueOrDefault() | Gets the value held by the interface file, or the default value of T when it holds none. |
| GetValueOrDefault(T) | Gets the value held by the interface file, or defaultValue when it holds none. |
| ToString() | Returns a string representation of this value. |
| TryGetValue(T) | Gets the value held by the interface file. |
Equals overloads
Equals(CGroupValue<T>)
CGroupValue.csIndicates whether the current object is equal to another object of the same type.
public bool Equals(CGroupValue<T> other)Parameters
otherCGroupValue<T>- An object to compare with this object.
Returns
bool true if the current object is equal to the other parameter; otherwise, false.
Equals(object?)
CGroupValue.csGetHashCode()
CGroupValue.csGetValueOrDefault overloads
GetValueOrDefault()
CGroupValue.csGets the value held by the interface file, or the default value of T when it holds none.
public T? GetValueOrDefault()Returns
T?
GetValueOrDefault(T)
CGroupValue.csGets the value held by the interface file, or defaultValue when it holds none.
public T GetValueOrDefault(T defaultValue)Parameters
defaultValueT- The value to return when the interface file holds no value.
Returns
T
ToString()
CGroupValue.csTryGetValue(T)
CGroupValue.csOperators
| Name | Description |
|---|---|
| operator ==(CGroupValue<T>, CGroupValue<T>) | Determines whether two values are equal. |
| operator !=(CGroupValue<T>, CGroupValue<T>) | Determines whether two values are different. |
operator ==(CGroupValue<T>, CGroupValue<T>)
CGroupValue.csDetermines whether two values are equal.
public static bool operator ==(CGroupValue<T> left, CGroupValue<T> right)Parameters
leftCGroupValue<T>- The first value to compare.
rightCGroupValue<T>- The second value to compare.
Returns
operator !=(CGroupValue<T>, CGroupValue<T>)
CGroupValue.csDetermines whether two values are different.
public static bool operator !=(CGroupValue<T> left, CGroupValue<T> right)Parameters
leftCGroupValue<T>- The first value to compare.
rightCGroupValue<T>- The second value to compare.