Struct ConvertedFieldValue
- Namespace
- Dynamicweb.Ecommerce.Feeds
- Assembly
- Dynamicweb.Ecommerce.dll
A numeric product field value that carries a unit symbol, as produced by a field value conversion (see FieldValueConversionService) or by a field type provider that appends a unit to the value.
public readonly record struct ConvertedFieldValue : IFormattable, IEquatable<ConvertedFieldValue>
- Implements
- Inherited Members
Remarks
The product view model exposes such a value as text that has already been rendered in the culture the server happened to be running in, which makes it the odd one out in a feed: every other numeric column is formatted in the culture of the language the feed is exported for. Data mapping feed providers therefore split that text back into its two parts, so the number can be re-formatted for the feed while the unit symbol is carried along unchanged.
Constructors
ConvertedFieldValue(double, string?)
A numeric product field value that carries a unit symbol, as produced by a field value conversion (see FieldValueConversionService) or by a field type provider that appends a unit to the value.
public ConvertedFieldValue(double Number, string? Unit)
Parameters
NumberdoubleThe numeric part of the value, expressed in
Unit.UnitstringThe unit symbol (e.g.
"kg","mm"), or null when the value carries none.
Remarks
The product view model exposes such a value as text that has already been rendered in the culture the server happened to be running in, which makes it the odd one out in a feed: every other numeric column is formatted in the culture of the language the feed is exported for. Data mapping feed providers therefore split that text back into its two parts, so the number can be re-formatted for the feed while the unit symbol is carried along unchanged.
Properties
Number
The numeric part of the value, expressed in Unit.
public double Number { get; init; }
Property Value
Unit
The unit symbol (e.g. "kg", "mm"), or null when the value carries none.
public string? Unit { get; init; }
Property Value
Methods
ToString()
Renders the value invariantly. Declared so that a caller which treats the value as a plain object - as every caller of the data mapping row values did before this type existed - still gets readable text instead of the record's default member listing.
public override string ToString()
Returns
ToString(string?, IFormatProvider?)
Renders the value as "number unit" - or as the bare number when it carries no unit - with the number
formatted for formatProvider. Pass the culture of the language the feed is
exported for; passing null renders invariant.
public string ToString(string? format, IFormatProvider? formatProvider)
Parameters
formatstringThe numeric format for the number part, or null for the format feed providers use.
formatProviderIFormatProviderThe format provider for the number part, or null for InvariantCulture.