public static IndentedString GetConstructors(IQuantityModel quantityModel)
        {
            return(new IndentedString(8, $@"
/// <summary>
/// Initializes a new instance of the <see cref=""{quantityModel.Name}""/> struct.
/// </summary>
/// <param name=""value"">The value.</param>
/// <param name=""unitSelector"">The unit selector.</param>
public {quantityModel.Name}(double value, SelectUnit<{quantityModel.Name}UnitSelector> unitSelector)
    : this(value,  UnitBuilder.BuildUnit(unitSelector(new {quantityModel.Name}UnitSelector())))
{{
}}

/// <summary>
/// Initializes a new instance of the <see cref=""{quantityModel.Name}""/> struct.
/// </summary>
/// <param name=""quantity"">The quantity.</param>
public {quantityModel.Name}(IQuantity quantity)
    : this(quantity.Value, quantity.Unit)
{{
}}

/// <summary>
/// Initializes a new instance of the <see cref=""{quantityModel.Name}""/> struct.
/// </summary>
/// <param name=""value"">The value.</param>
public {quantityModel.Name}(double value)
    : this(value, units => units.BaseUnit)
{{
}}

/// <summary>
/// Initializes a new instance of the <see cref=""{quantityModel.Name}""/> struct.
/// </summary>
/// <param name=""value"">The value.</param>
/// <param name=""unit"">The unit.</param>
public {quantityModel.Name}(double value, IUnit unit)
{{
    this.value = value;
    this.Unit = unit;
}}
"));
        }
示例#2
0
        public static IndentedString GetUnits(IQuantityModel modelModel)
        {
            var stringBuilder = new StringBuilder();

            foreach (var modelDefinitionUnit in modelModel.Units)
            {
                stringBuilder.AppendLine($@"
/// <summary>
/// Gets the {GetDocumentationName(modelDefinitionUnit)} expression.
/// </summary>
/// <value>
/// The {GetDocumentationName(modelDefinitionUnit)}.
/// </value>
public Expression {modelDefinitionUnit.Identifier} => this.SpecifyUnit(UnitDefinitions.{GetUnitName(modelDefinitionUnit)});
");
            }

            return(new IndentedString(8, stringBuilder.ToString()));
        }
        public static IndentedString GetExponents(IQuantityModel modelModel)
        {
            return(new IndentedString(8, $@"
/// <summary>
/// Gets the square.
/// </summary>
/// <value>
/// The square.
/// </value>
public {PrefixesHelper.GetPrefixesAndUnitsInterface(modelModel)} Square => this.GetPrefixesAndUnits(2);

/// <summary>
/// Gets the cubic.
/// </summary>
/// <value>
/// The cubic.
/// </value>
public {PrefixesHelper.GetPrefixesAndUnitsInterface(modelModel)} Cubic => this.GetPrefixesAndUnits(3);

/// <summary>
/// Gets the quartic.
/// </summary>
/// <value>
/// The quartic.
/// </value>
public {PrefixesHelper.GetPrefixesAndUnitsInterface(modelModel)} Quartic => this.GetPrefixesAndUnits(4);

/// <summary>
/// Gets the quintic.
/// </summary>
/// <value>
/// The quintic.
/// </value>
public {PrefixesHelper.GetPrefixesAndUnitsInterface(modelModel)} Quintic => this.GetPrefixesAndUnits(5);
"));
        }
示例#4
0
 internal static string GetPrefixesAndUnitsInterface(IQuantityModel quantityModel)
 {
     return($"IPrefixed{quantityModel.Name}UnitSelector");
 }
示例#5
0
 internal static string GetUnitsInterface(IQuantityModel quantityModel)
 {
     return($"I{quantityModel.Name}UnitSelector");
 }
示例#6
0
        public static IndentedString GetPrefixes(IQuantityModel quantityModel)
        {
            return(new IndentedString(8, $@"
/// <summary>
/// Gets the yotta.
/// </summary>
/// <value>
/// The yotta.
/// </value>
public {GetUnitsInterface(quantityModel)} Yotta => this.GetUnits(Prefixes.Yotta);

/// <summary>
/// Gets the zetta.
/// </summary>
/// <value>
/// The zetta.
/// </value>
public {GetUnitsInterface(quantityModel)} Zetta => this.GetUnits(Prefixes.Zetta);

/// <summary>
/// Gets the exa.
/// </summary>
/// <value>
/// The exa.
/// </value>
public {GetUnitsInterface(quantityModel)} Exa => this.GetUnits(Prefixes.Exa);

/// <summary>
/// Gets the peta.
/// </summary>
/// <value>
/// The peta.
/// </value>
public {GetUnitsInterface(quantityModel)} Peta => this.GetUnits(Prefixes.Peta);

/// <summary>
/// Gets the tera.
/// </summary>
/// <value>
/// The tera.
/// </value>
public {GetUnitsInterface(quantityModel)} Tera => this.GetUnits(Prefixes.Tera);

/// <summary>
/// Gets the giga.
/// </summary>
/// <value>
/// The giga.
/// </value>
public {GetUnitsInterface(quantityModel)} Giga => this.GetUnits(Prefixes.Giga);

/// <summary>
/// Gets the mega.
/// </summary>
/// <value>
/// The mega.
/// </value>
public {GetUnitsInterface(quantityModel)} Mega => this.GetUnits(Prefixes.Mega);

/// <summary>
/// Gets the kilo.
/// </summary>
/// <value>
/// The kilo.
/// </value>
public {GetUnitsInterface(quantityModel)} Kilo => this.GetUnits(Prefixes.Kilo);

/// <summary>
/// Gets the hecto.
/// </summary>
/// <value>
/// The hecto.
/// </value>
public {GetUnitsInterface(quantityModel)} Hecto => this.GetUnits(Prefixes.Hecto);

/// <summary>
/// Gets the deca.
/// </summary>
/// <value>
/// The deca.
/// </value>
public {GetUnitsInterface(quantityModel)} Deca => this.GetUnits(Prefixes.Deca);

/// <summary>
/// Gets the deci.
/// </summary>
/// <value>
/// The deci.
/// </value>
public {GetUnitsInterface(quantityModel)} Deci => this.GetUnits(Prefixes.Deci);

/// <summary>
/// Gets the centi.
/// </summary>
/// <value>
/// The centi.
/// </value>
public {GetUnitsInterface(quantityModel)} Centi => this.GetUnits(Prefixes.Centi);

/// <summary>
/// Gets the milli.
/// </summary>
/// <value>
/// The milli.
/// </value>
public {GetUnitsInterface(quantityModel)} Milli => this.GetUnits(Prefixes.Milli);

/// <summary>
/// Gets the micro.
/// </summary>
/// <value>
/// The micro.
/// </value>
public {GetUnitsInterface(quantityModel)} Micro => this.GetUnits(Prefixes.Micro);

/// <summary>
/// Gets the nano.
/// </summary>
/// <value>
/// The nano.
/// </value>
public {GetUnitsInterface(quantityModel)} Nano => this.GetUnits(Prefixes.Nano);

/// <summary>
/// Gets the pico.
/// </summary>
/// <value>
/// The pico.
/// </value>
public {GetUnitsInterface(quantityModel)} Pico => this.GetUnits(Prefixes.Pico);

/// <summary>
/// Gets the femto.
/// </summary>
/// <value>
/// The femto.
/// </value>
public {GetUnitsInterface(quantityModel)} Femto => this.GetUnits(Prefixes.Femto);

/// <summary>
/// Gets the atto.
/// </summary>
/// <value>
/// The atto.
/// </value>
public {GetUnitsInterface(quantityModel)} Atto => this.GetUnits(Prefixes.Atto);

/// <summary>
/// Gets the zepto.
/// </summary>
/// <value>
/// The zepto.
/// </value>
public {GetUnitsInterface(quantityModel)} Zepto => this.GetUnits(Prefixes.Zepto);

/// <summary>
/// Gets the yocto.
/// </summary>
/// <value>
/// The yocto.
/// </value>
public {GetUnitsInterface(quantityModel)} Yocto => this.GetUnits(Prefixes.Yocto);
"));
        }
        public static IndentedString GetEqualityOperations(IQuantityModel quantityModel)
        {
            return(new IndentedString(8, $@"
/// <summary>
/// Returns a hash code for this instance.
/// </summary>
/// <returns>
/// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
/// </returns>
public override int GetHashCode()
{{
    return QuantityHelper.GetHashCode(this);
}}

/// <summary>
/// Determines whether the specified <see cref=""object"" />, is equal to this instance.
/// </summary>
/// <param name=""obj"">The <see cref=""object"" /> to compare with this instance.</param>
/// <returns>
///   <c>true</c> if the specified <see cref=""object"" /> is equal to this instance; otherwise, <c>false</c>.
/// </returns>
public override bool Equals(object obj)
{{
    return QuantityHelper.AreEqual(this, obj);
}}

/// <summary>
/// Determines whether the specified <see cref=""IQuantity"" />, is equal to this instance.
/// </summary>
/// <param name=""quantity"">The quantity.</param>
/// <returns>
///   <c>true</c> if the specified <see cref=""IQuantity"" /> is equal to this instance; otherwise, <c>false</c>.
/// </returns>
public bool Equals(IQuantity quantity)
{{
    return QuantityHelper.AreEqual(this, quantity);
}}

/// <summary>
/// Determines whether the specified <see cref=""{quantityModel.Name}"" />, is equal to this instance.
/// </summary>
/// <param name=""quantity"">The quantity.</param>
/// <returns>
///   <c>true</c> if the specified <see cref=""{quantityModel.Name}"" /> is equal to this instance; otherwise, <c>false</c>.
/// </returns>
public bool Equals({quantityModel.Name} quantity)
{{
    return QuantityHelper.AreEqual(this, quantity);
}}

/// <summary>
/// Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
/// </summary>
/// <param name=""obj"">An object to compare with this instance.</param>
/// <returns>
/// A value that indicates the relative order of the objects being compared. The return value has these meanings: Value Meaning Less than zero This instance precedes <paramref name=""obj"" /> in the sort order. Zero This instance occurs in the same position in the sort order as <paramref name=""obj"" />. Greater than zero This instance follows <paramref name=""obj"" /> in the sort order.
/// </returns>
public int CompareTo(object obj)
{{
    return QuantityHelper.CompareTo<{quantityModel.Name}>(this, obj);
}}

/// <summary>
/// Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
/// </summary>
/// <param name=""quantity"">A quantityModel to compare with this instance.</param>
/// <returns>
/// A value that indicates the relative order of the objects being compared. The return value has these meanings: Value Meaning Less than zero This instance precedes <paramref name=""quantity"" /> in the sort order. Zero This instance occurs in the same position in the sort order as <paramref name=""quantity"" />. Greater than zero This instance follows <paramref name=""quantity"" /> in the sort order.
/// </returns>
public int CompareTo(IQuantity quantity)
{{
    return QuantityHelper.CompareTo(this, quantity);
}}

/// <summary>
/// Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
/// </summary>
/// <param name=""quantity"">A quantity to compare with this instance.</param>
/// <returns>
/// A value that indicates the relative order of the objects being compared. The return value has these meanings: Value Meaning Less than zero This instance precedes <paramref name=""quantity"" /> in the sort order. Zero This instance occurs in the same position in the sort order as <paramref name=""quantity"" />. Greater than zero This instance follows <paramref name=""quantity"" /> in the sort order.
/// </returns>
public int CompareTo({quantityModel.Name} quantity)
{{
    return QuantityHelper.CompareTo(this, quantity);
}}
"));
        }
        public static IndentedString GetToStringOperations(IQuantityModel quantityModel)
        {
            return(new IndentedString(8, @"
/// <summary>
/// Returns a <see cref=""string"" /> that represents this instance.
/// </summary>
/// <returns>
/// A <see cref=""string"" /> that represents this instance.
/// </returns>
public override string ToString()
{{
    return this.ToString(CultureInfo.CurrentCulture);
}}

/// <summary>
/// Returns a <see cref=""string"" /> that represents this instance.
/// </summary>
/// <param name=""unitFormat"">The unit format.</param>
/// <returns>
/// A <see cref=""string"" /> that represents this instance.
/// </returns>
public string ToString(UnitFormat unitFormat)
{{
    return this.ToString(unitFormat, null, CultureInfo.CurrentCulture);
}}

/// <summary>
/// Returns a <see cref=""string"" /> that represents this instance.
/// </summary>
/// <param name=""format"">The format.</param>
/// <returns>
/// A <see cref=""string"" /> that represents this instance.
/// </returns>
public string ToString(string format)
{{
    return this.ToString(format, CultureInfo.CurrentCulture);
}}

/// <summary>
/// Returns a <see cref=""string"" /> that represents this instance.
/// </summary>
/// <param name=""formatProvider"">The format provider.</param>
/// <returns>
/// A <see cref=""string"" /> that represents this instance.
/// </returns>
public string ToString(IFormatProvider formatProvider)
{{
    return this.ToString(null, formatProvider);
}}

/// <summary>
/// Returns a <see cref=""string"" /> that represents this instance.
/// </summary>
/// <param name=""unitFormat"">The unit format.</param>
/// <param name=""format"">The format.</param>
/// <returns>
/// A <see cref=""string"" /> that represents this instance.
/// </returns>
public string ToString(UnitFormat unitFormat, string format)
{{
    return this.ToString(unitFormat, format, CultureInfo.CurrentCulture);
}}

/// <summary>
/// Returns a <see cref=""string"" /> that represents this instance.
/// </summary>
/// <param name=""unitFormat"">The unit format.</param>
/// <param name=""formatProvider"">The format provider.</param>
/// <returns>
/// A <see cref=""string"" /> that represents this instance.
/// </returns>
public string ToString(UnitFormat unitFormat, IFormatProvider formatProvider)
{{
    return this.ToString(unitFormat, null, formatProvider);
}}

/// <summary>
/// Returns a <see cref=""string"" /> that represents this instance.
/// </summary>
/// <param name=""format"">The format.</param>
/// <param name=""formatProvider"">The format provider.</param>
/// <returns>
/// A <see cref=""string"" /> that represents this instance.
/// </returns>
public string ToString(string format, IFormatProvider formatProvider)
{{
    return this.ToString(UnitFormat.Default, format, formatProvider);
}}

/// <summary>
/// Returns a <see cref=""string"" /> that represents this instance.
/// </summary>
/// <param name=""unitFormat"">The unit format.</param>
/// <param name=""format"">The format.</param>
/// <param name=""formatProvider"">The format provider.</param>
/// <returns>
/// A <see cref=""string"" /> that represents this instance.
/// </returns>
public string ToString(UnitFormat unitFormat, string format, IFormatProvider formatProvider)
{{
    return QuantityHelper.ToString(
        this.Unit.FormatValue(this.value, format, formatProvider),
        UnitFormatHelper.GetNotation(this.Unit, unitFormat));
}}
"));
        }
        public static IndentedString GetStandardOperations(IQuantityModel quantityModel)
        {
            return(new IndentedString(8, $@"
/// <summary>
/// Implements the unary + operator.
/// </summary>
/// <param name=""quantity"">The quantity.</param>
/// <returns>
/// The <paramref name=""quantity""/>.
/// </returns>
public static {quantityModel.Name} operator +({quantityModel.Name} quantity)
{{
    return quantity;
}}

/// <summary>
/// Implements the unary - operator.
/// </summary>
/// <param name=""quantity"">The quantity.</param>
/// <returns>
/// The negated <paramref name=""quantity""/>.
/// </returns>
public static {quantityModel.Name} operator -({quantityModel.Name} quantity)
{{
    return new {quantityModel.Name}(-quantity.value, quantity.Unit);
}}

/// <summary>
/// Increaments the specified <see cref=""{quantityModel.Name}""/>.
/// </summary>
/// <param name=""quantity"">The quantity.</param>
/// <returns>
/// An increamented <see cref=""{quantityModel.Name}""/>.
/// </returns>
public static {quantityModel.Name} operator ++({quantityModel.Name} quantity)
{{
    return new {quantityModel.Name}(quantity.value + 1, quantity.Unit);
}}

/// <summary>
/// Decreaments the specified <see cref=""{quantityModel.Name}""/>.
/// </summary>
/// <param name=""quantity"">The quantity.</param>
/// <returns>
/// An decreamented <see cref=""{quantityModel.Name}""/>.
/// </returns>
public static {quantityModel.Name} operator --({quantityModel.Name} quantity)
{{
    return new {quantityModel.Name}(quantity.value - 1, quantity.Unit);
}}

/// <summary>
/// Adds the specified rhs to the specified lhs.
/// </summary>
/// <param name=""lhs"">The LHS.</param>
/// <param name=""rhs"">The RHS.</param>
/// <returns>
/// A <see cref=""{quantityModel.Name}""/>.
/// </returns>
public static {quantityModel.Name} operator +({quantityModel.Name} lhs, double rhs)
{{
    return new {quantityModel.Name}(lhs.value + rhs, lhs.Unit);
}}

/// <summary>
/// Subtracts the specified rhs from the specified lhs.
/// </summary>
/// <param name=""lhs"">The LHS.</param>
/// <param name=""rhs"">The RHS.</param>
/// <returns>
/// A <see cref=""{quantityModel.Name}""/>.
/// </returns>
public static {quantityModel.Name} operator -({quantityModel.Name} lhs, double rhs)
{{
    return new {quantityModel.Name}(lhs.value - rhs, lhs.Unit);
}}

/// <summary>
/// Multiplies the specified lhs by the specified rhs.
/// </summary>
/// <param name=""lhs"">The LHS.</param>
/// <param name=""rhs"">The RHS.</param>
/// <returns>
/// A <see cref=""{quantityModel.Name}""/>.
/// </returns>
public static {quantityModel.Name} operator *({quantityModel.Name} lhs, double rhs)
{{
    return new {quantityModel.Name}(lhs.value * rhs, lhs.Unit);
}}

/// <summary>
/// Divides the specified lhs by the specified rhs.
/// </summary>
/// <param name=""lhs"">The LHS.</param>
/// <param name=""rhs"">The RHS.</param>
/// <returns>
/// A <see cref=""{quantityModel.Name}""/>.
/// </returns>
public static {quantityModel.Name} operator /({quantityModel.Name} lhs, double rhs)
{{
    return new {quantityModel.Name}(lhs.value / rhs, lhs.Unit);
}}

/// <summary>
/// Adds the specified rhs to the specified lhs.
/// </summary>
/// <param name=""lhs"">The LHS.</param>
/// <param name=""rhs"">The RHS.</param>
/// <returns>
/// A <see cref=""{quantityModel.Name}""/>.
/// </returns>
public static {quantityModel.Name} operator +({quantityModel.Name} lhs, {quantityModel.Name} rhs)
{{
    return new {quantityModel.Name}(QuantityOperations.Add(lhs, rhs));
}}

/// <summary>
/// Subtracts the specified rhs from the specified lhs.
/// </summary>
/// <param name=""lhs"">The LHS.</param>
/// <param name=""rhs"">The RHS.</param>
/// <returns>
/// A <see cref=""{quantityModel.Name}""/>.
/// </returns>
public static {quantityModel.Name} operator -({quantityModel.Name} lhs, {quantityModel.Name} rhs)
{{
    return new {quantityModel.Name}(QuantityOperations.Subtract(lhs, rhs));
}}

/// <summary>
/// Divides the specified lhs by the specified rhs.
/// </summary>
/// <param name=""lhs"">The LHS.</param>
/// <param name=""rhs"">The RHS.</param>
/// <returns>
/// A <see cref=""{quantityModel.Name}""/>.
/// </returns>
public static double operator /({quantityModel.Name} lhs, {quantityModel.Name} rhs)
{{
    return QuantityOperations.Divide(lhs, rhs).Value;
}}

/// <summary>
/// Determines whether the specified rhs, is equal to the lhs.
/// </summary>
/// <param name=""lhs"">The LHS.</param>
/// <param name=""rhs"">The RHS.</param>
/// <returns>
///   <c>true</c> if the specified rhs is equal to the lhs; otherwise, <c>false</c>.
/// </returns>
public static bool operator ==({quantityModel.Name} lhs, {quantityModel.Name} rhs)
{{
    return QuantityHelper.AreEqual(lhs, rhs);
}}

/// <summary>
/// Determines whether the specified rhs, is different from the lhs.
/// </summary>
/// <param name=""lhs"">The LHS.</param>
/// <param name=""rhs"">The RHS.</param>
/// <returns>
///   <c>true</c> if the specified rhs is different to the lhs; otherwise, <c>false</c>.
/// </returns>
public static bool operator !=({quantityModel.Name} lhs, {quantityModel.Name} rhs)
{{
    return !QuantityHelper.AreEqual(lhs, rhs);
}}

/// <summary>
/// Compares whether the specified lhs is greather than or equal to the rhs.
/// </summary>
/// <param name=""lhs"">The LHS.</param>
/// <param name=""rhs"">The RHS.</param>
/// <returns>
///   <c>true</c> if the specified lhs is greater than or equal to the rhs; otherwise, <c>false</c>.
/// </returns>
public static bool operator >=({quantityModel.Name} lhs, {quantityModel.Name} rhs)
{{
    return QuantityHelper.CompareTo(lhs, rhs) >= 0;
}}

/// <summary>
/// Compares whether the specified lhs is less than or equal to the rhs.
/// </summary>
/// <param name=""lhs"">The LHS.</param>
/// <param name=""rhs"">The RHS.</param>
/// <returns>
///   <c>true</c> if the specified lhs is less than or equal to the rhs; otherwise, <c>false</c>.
/// </returns>
public static bool operator <=({quantityModel.Name} lhs, {quantityModel.Name} rhs)
{{
    return QuantityHelper.CompareTo(lhs, rhs) <= 0;
}}

/// <summary>
/// Compares whether the specified lhs is greather than the rhs.
/// </summary>
/// <param name=""lhs"">The LHS.</param>
/// <param name=""rhs"">The RHS.</param>
/// <returns>
///   <c>true</c> if the specified lhs is greater than or rhs; otherwise, <c>false</c>.
/// </returns>
public static bool operator >({quantityModel.Name} lhs, {quantityModel.Name} rhs)
{{
    return QuantityHelper.CompareTo(lhs, rhs) > 0;
}}

/// <summary>
/// Compares whether the specified lhs is less than the rhs.
/// </summary>
/// <param name=""lhs"">The LHS.</param>
/// <param name=""rhs"">The RHS.</param>
/// <returns>
///   <c>true</c> if the specified lhs is less than the rhs; otherwise, <c>false</c>.
/// </returns>
public static bool operator <({quantityModel.Name} lhs, {quantityModel.Name} rhs)
{{
    return QuantityHelper.CompareTo(lhs, rhs) < 0;
}}

/// <summary>
/// Creates an <see cref=""Interval""/> with the specified minimum, maximum and unit.
/// </summary>
/// <param name=""min"">The minimum.</param>
/// <param name=""max"">The maximum.</param>
/// <param name=""unitSelector"">The unit selector.</param>
/// <returns>
/// An <see cref=""Interval""/>.
/// </returns>
public static Interval<{quantityModel.Name}> Interval(double min, double max, SelectUnit<{quantityModel.Name}UnitSelector> unitSelector)
{{
    return new Interval<{quantityModel.Name}>(min, max, unitSelector(new {quantityModel.Name}UnitSelector()));
}}

/// <summary>
/// Squares this instance.
/// </summary>
/// <returns>
/// A <see cref=""Squared{{{quantityModel.Name}}}""/>.
/// </returns>
public Squared<{quantityModel.Name}> Squared()
{{
    return new Squared<{quantityModel.Name}>(this);
}}

/// <summary>
/// Cubes this instance.
/// </summary>
/// <returns>
/// A <see cref=""Cubed{{{quantityModel.Name}}}""/>.
/// </returns>
public Cubed<{quantityModel.Name}> Cubed()
{{
    return new Cubed<{quantityModel.Name}>(this);
}}
"));
        }
        public static IndentedString GetConversionOperations(IQuantityModel quantityModel)
        {
            return(new IndentedString(8, $@"
/// <summary>
/// Converts this object to a <see cref=""double"" /> using the specified unit.
/// </summary>
/// <param name=""unit"">The quantity unit.</param>
/// <returns>
/// The converted <see cref=""double"" />.
/// </returns>
public double ToDouble(IUnit unit)
{{
    return QuantityOperations.ConvertToUnit(this, unit);
}}

/// <summary>
/// Converts this object to a <see cref=""IQuantity"" /> using the unit specified by the <see cref=""IUnit"" />.
/// </summary>
/// <param name=""unit"">The target unit.</param>
/// <returns>
/// The resulting <see cref=""IQuantity"" />.
/// </returns>
public IQuantity ToQuantity(IUnit unit)
{{
    return this.ToUnit(unit);
}}

/// <summary>
/// Converts this object to a <see cref=""{quantityModel.Name}"" /> using the specified unit.
/// </summary>
/// <param name=""unit"">The quantity unit.</param>
/// <returns>
/// The converted <see cref=""{quantityModel.Name}"" />.
/// </returns>
public {quantityModel.Name} ToUnit(IUnit unit)
{{
    return new {quantityModel.Name}(this.ToDouble(unit), unit);
}}

/// <summary>
/// Converts this object to a <see cref=""{quantityModel.Name}"" /> using the unit specified by the <see cref=""{quantityModel.Name}UnitSelector"" />.
/// </summary>
/// <param name=""unitSelector"">The unit selector.</param>
/// <returns>
/// The converted <see cref=""{quantityModel.Name}"" />.
/// </returns>
public {quantityModel.Name} ToUnit(SelectUnit<{quantityModel.Name}UnitSelector> unitSelector)
{{
    return this.ToUnit(UnitBuilder.BuildUnit(unitSelector(new {quantityModel.Name}UnitSelector())));
}}

/// <summary>
/// Converts this object to a <see cref=""double"" /> using the unit specified by the <see cref=""{quantityModel.Name}UnitSelector"" />.
/// </summary>
/// <param name=""unitSelector"">The unit selector.</param>
/// <returns>
/// The converted <see cref=""double"" />.
/// </returns>
public double ToDouble(SelectUnit<{quantityModel.Name}UnitSelector> unitSelector)
{{
    return this.ToDouble(UnitBuilder.BuildUnit(unitSelector(new {quantityModel.Name}UnitSelector())));
}}
"));
        }