public static PressureDropITem Parse(string s, IHashable hashable, IFormatProvider formatProvider) { var dValue = double.TryParse(s, out double r); var unit = hashable.GetHashableUnit(OwnerUnitPropertyName); if (string.IsNullOrWhiteSpace(unit)) { unit = hashable.GetHashableUnit("Water" + OwnerUnitPropertyName); } if (dValue) { if (!string.IsNullOrWhiteSpace(unit)) { return(PressureDropITem.Factory.Create(r, unit)); } else { return(PressureDropITem.Factory.Create(r, U.kPa)); } } else { Regex regex = new Regex(@"\d+"); Match match = regex.Match(s); var isNumber = double.TryParse(match.Value, out double v); if (isNumber) { if (!string.IsNullOrWhiteSpace(unit)) { return(PressureDropITem.Factory.Create(v, unit)); } else { return(PressureDropITem.Factory.Create(v, U.kPa)); } } if (!string.IsNullOrWhiteSpace(unit)) { return(PressureDropITem.Factory.Create(0, unit)); } else { return(PressureDropITem.Factory.Create(0, U.kPa)); } } }
public static AirFlowItem Parse(string s, IHashable hashable, IFormatProvider formatProvider) { var dValue = double.TryParse(s, out double r); var unit = hashable.GetHashableUnit("AirFlowUnit"); if (dValue) { if (!string.IsNullOrWhiteSpace(unit)) { return(AirFlowItem.Factory.Create(r, unit)); } else { return(AirFlowItem.Factory.Create(r, U.LpS)); } } else { Regex regex = new Regex(@"\d+"); Match match = regex.Match(s); var isNumber = double.TryParse(match.Value, out double v); if (isNumber) { if (!string.IsNullOrWhiteSpace(unit)) { return(AirFlowItem.Factory.Create(v, unit)); } else { return(AirFlowItem.Factory.Create(v, U.LpS)); } } if (!string.IsNullOrWhiteSpace(unit)) { return(AirFlowItem.Factory.Create(0, unit)); } else { return(AirFlowItem.Factory.Create(0, U.LpS)); } } }
public static PipeSizeItem Parse(string s, IHashable hashable, IFormatProvider formatProvider) { var dValue = PipeSizeTableItem.AllData.Where(xi => xi.ValueInMM == s || xi.ValueInInch == s).FirstOrDefault(); if (dValue != null) { var ss_value = PipeSizeTableItem.AllData.Where(xi => xi.ValueInMM == s).FirstOrDefault(); if (ss_value != null) { return(Factory.Create(ss_value.ValueInMM, U.mm)); } else { return(Factory.Create(ss_value.ValueInInch, U.inch)); } } else { Regex regex = new Regex(@"\d+"); Match match = regex.Match(s); var isNumber = double.TryParse(match.Value, out double v); if (isNumber) { var unit = hashable.GetHashableUnit(OwnerUnitPropertyName); if (!string.IsNullOrWhiteSpace(unit)) { return(PipeSizeItem.Factory.Create(s, unit)); } else { return(PipeSizeItem.Factory.Create(s, U.mm)); } } return(Factory.Create(PipeSizeTableItem.AllData.First().ValueInMM, U.mm)); } }