Class DataValueDescriptor
The default IDataValueDescriptor implementation.
public class DataValueDescriptor : IDataValueDescriptor
- Inheritance
-
DataValueDescriptor
- Implements
- Derived
- Inherited Members
Constructors
DataValueDescriptor(string, string, string)
Initializes a new instance of the DataValueDescriptor class.
public DataValueDescriptor(string displayFormat, string serializeFormat, string units)
Parameters
displayFormat
stringThe display format, for use with ToString(string, IFormatProvider).
serializeFormat
stringThe serialize format, for use with ToString(string, IFormatProvider).
units
stringThe units, or null.
Exceptions
- ArgumentNullException
displayFormat
is null.- ArgumentNullException
serializeFormat
is null.
Properties
Basic
Gets a data value descriptor that does not use units and or any special value formatting.
public static DataValueDescriptor Basic { get; }
Property Value
Units
Gets the units of measurement, or null if there are none.
public string Units { get; }
Property Value
Methods
Format(object, string, IFormatProvider)
Formats a data value using the specified format.
public virtual string Format(object value, string format, IFormatProvider formatProvider)
Parameters
value
objectThe value to format.
format
stringThe format to use (see remarks), or null to use the default display format ("D").
formatProvider
IFormatProviderThe provider to use to format the value, or null to obtain the format information from the current locale setting of the operating system.
Returns
- string
The value of the current instance in the specified format.
Remarks
The following format values are valid for format
:
G
- The general format, which is the same as D
.
D
- The display format, which includes the formatted data value along with the units, if it has any. Example: 1,234.5 psi
V
- The value format, which is the display format without units. Example: 1,234.5
S
- The serialization format. Note that formatProvider
is ignored (InvariantCulture is always used). Example: 1234.5
Exceptions
- FormatException
The format string is not supported.