示例#1
0
        public static string ToStringFormat <T>(this IUnitedValue <T> value, string format, IFormatProvider provider)
            where T : IUnit, IEquatable <T>
        {
            if (string.IsNullOrEmpty(format))
            {
                format = "G";
            }
            if (provider == null)
            {
                provider = CultureInfo.CurrentCulture;
            }

            format = format.ToUpperInvariant().Trim();
            if (format.StartsWith("F"))
            {
                var tmp = format.Substring(1);
                int value1;
                if (int.TryParse(tmp, out value1))
                {
                    return(value.Value.ToString(format, provider) + " " + value.Unit);
                }
            }

            return(value.Value.ToString("F2", provider) + " " + value.Unit);
        }
示例#2
0
 public bool Equals(IUnitedValue <DensityUnit> other)
 {
     if (other is null)
     {
         return(false);
     }
     return(Value == other.Value && !(Unit is null) && Unit.Equals(other.Unit));
 }
示例#3
0
 public bool Equals(IUnitedValue <QuotientUnit <TCounter, TDenominator> > other)
 {
     if (other == null)
     {
         return(false);
     }
     return(Value.Equals(other.Value) && Unit.Equals(other.Unit));
 }
 public bool Equals(IUnitedValue <CelsiusTemperatureUnit> other)
 {
     if (other is null)
     {
         return(false);
     }
     return(Value == other.Value && !(Unit is null) && Unit.Equals(other.Unit));
 }
 public bool Equals(IUnitedValue <LinearPowerLossUnit> other)
 {
     if (other is null)
     {
         return(false);
     }
     return(Value == other.Value && !(Unit is null) && Unit.Equals(other.Unit));
 }
 public bool Equals(IUnitedValue <ThermalResistanceUnit> other)
 {
     if (other is null)
     {
         return(false);
     }
     return(Value == other.Value && !(Unit is null) && Unit.Equals(other.Unit));
 }
 public bool Equals(IUnitedValue <SpecificHeatCapacityUnit> other)
 {
     if (other is null)
     {
         return(false);
     }
     return(Value == other.Value && !(Unit is null) && Unit.Equals(other.Unit));
 }
示例#8
0
 public bool Equals(IUnitedValue <MassDetlaKelvinUnit> other)
 {
     if (other is null)
     {
         return(false);
     }
     return(Value == other.Value && !(Unit is null) && Unit.Equals(other.Unit));
 }
 public static string MakeMessage <T>(IUnitedValue <T> temp, string a, string b)
     where T : IUnit, IEquatable <T>
 {
     return($"Unable to convert {a} in {temp.Unit} into {b}.");
 }
示例#10
0
 public bool Equals(IUnitedValue<KelvinTemperatureUnit> other)
 {
     if (other is null)
         return false;
     return Value == other.Value && !(Unit is null) && Unit.Equals(other.Unit);
 }