-
Notifications
You must be signed in to change notification settings - Fork 0
9ad2a840 bea5 1535 52d0 744fde18965b
Capacity formatter provides functionality to easily format capacity values.
System.Object
Plexdata.Formatters.CapacityFormatter
Namespace: Plexdata.Formatters
Assembly: Plexdata.CapacityConverter (in Plexdata.CapacityConverter.dll) Version: 1.0.1
C#
public class CapacityFormatter : IFormatProvider,
ICustomFormatter
The CapacityFormatter type exposes the following members.
Name | Description | |
---|---|---|
CapacityFormatter() | Default constructor. | |
CapacityFormatter(CultureInfo) | Parameterized constructor. |
Name | Description | |
---|---|---|
Culture | Gets the used culture. | |
Supported | Gets the list of supported types. |
Name | Description | |
---|---|---|
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
Format | Converts the value of a specified object to an equivalent string representation using specified format and culture-specific formatting information. | |
GetCalculate | Gets current calculate mode from provided format string. | |
GetCulture | Determines the used culture. | |
GetDecimals | Extracts the decimal digits from provided format string. | |
GetFormat | Returns an object that provides formatting services for the specified type. | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetIntercept | Gets current intercept mode from provided format string. | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
GetUnit | Extracts the unit name from provided format string. | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Capacity formatter is intended to be used in any string format operation that wants to display a size in an appropriated byte format. Such an example could be to display a file size in its megabyte representation.
Assuming a file has a size of 9,876,543 bytes and this size should be shown in its megabyte representation with three decimal digits. Is this case the capacity formatter would be used as shown as follows.
// Result: "The file size is 9.419 MB."
String.Format(new CapacityFormatter(), "The file size is {0:MB3}.", 9876543);
Keep in mind, this usage as shown above is the recommended way. Other ways may work but without guarantee.
Plexdata Capacity Converter