Skip to content

9ad2a840 bea5 1535 52d0 744fde18965b

Axel Kesseler edited this page Oct 3, 2019 · 3 revisions

CapacityFormatter Class

Capacity formatter provides functionality to easily format capacity values.

Inheritance Hierarchy

System.Object
  Plexdata.Formatters.CapacityFormatter
Namespace: Plexdata.Formatters
Assembly: Plexdata.CapacityConverter (in Plexdata.CapacityConverter.dll) Version: 1.0.1

Syntax

C#

public class CapacityFormatter : IFormatProvider, 
	ICustomFormatter

The CapacityFormatter type exposes the following members.

Constructors

 

Name Description
Public method CapacityFormatter() Default constructor.
Public method CapacityFormatter(CultureInfo) Parameterized constructor.
  Back to Top

Properties

 

Name Description
Public property Culture Gets the used culture.
Public property Supported Gets the list of supported types.
  Back to Top

Methods

 

Name Description
Public method Equals Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method Format Converts the value of a specified object to an equivalent string representation using specified format and culture-specific formatting information.
Private method GetCalculate Gets current calculate mode from provided format string.
Private method GetCulture Determines the used culture.
Private method GetDecimals Extracts the decimal digits from provided format string.
Public method GetFormat Returns an object that provides formatting services for the specified type.
Public method GetHashCode Serves as the default hash function. (Inherited from Object.)
Private method GetIntercept Gets current intercept mode from provided format string.
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Private method GetUnit Extracts the unit name from provided format string.
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)
  Back to Top

Remarks

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.

Examples

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.

See Also

Reference

Plexdata.Formatters Namespace

Clone this wiki locally