public void NormalizeNumberStrings(AssetSettingsDTO parsedDTO) { this.Dust = this.Dust.Replace(',', '.'); //todo fix locale NormalizeNumberString("MinBalance", parsedDTO); NormalizeNumberString("MaxBalance", parsedDTO); NormalizeNumberString("OutputSize", parsedDTO); NormalizeNumberString("CashinCoef", parsedDTO); NormalizeNumberString("Dust", parsedDTO); }
private void NormalizeNumberString(string propertyName, AssetSettingsDTO parsedDTO) { PropertyInfo property = this.GetType().GetProperty(propertyName); if (property != null) { object localValueObject = property.GetValue(this); object parsedValueObject = property.GetValue(parsedDTO); if (localValueObject != null && parsedValueObject != null) { string localValue = localValueObject.ToString(); string parsedValue = parsedValueObject.ToString(); if (localValue.Length > parsedValue.Length) { property.SetValue(this, localValue.Substring(0, parsedValue.Length)); } } } }