public void FromOldFormat(string asset, CultureInfo cultureInfo) { asset = MultyZeroRegex.Replace(asset, "0"); var args = asset.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (args.Length != 2) { throw new InvalidCastException($"Error cast {asset} to Asset"); } switch (args[1]) { case Config.Sbd: Symbol = new AssetSymbolType(Config.SteemAssetNumSbd); break; case Config.Steem: Symbol = new AssetSymbolType(Config.SteemAssetNumSteem); break; case Config.Vests: Symbol = new AssetSymbolType(Config.SteemAssetNumVests); break; default: throw new InvalidCastException($"Error cast {asset} to Asset"); } var val = args[0].Replace(cultureInfo.NumberFormat.NumberGroupSeparator, ""); var dec = val.IndexOf(cultureInfo.NumberFormat.NumberDecimalSeparator, StringComparison.Ordinal); string amount; if (dec > -1) { dec = val.Length - dec - 1; if (dec > Symbol.Decimals()) { throw new InvalidCastException($"Error cast {asset} to Asset"); } amount = val.Replace(cultureInfo.NumberFormat.NumberDecimalSeparator, ""); if (dec != Symbol.Decimals()) { amount += new string('0', Symbol.Decimals() - dec); } } else { amount = val + new string('0', Symbol.Decimals()); } Amount = long.Parse(amount); }
public void FromNewFormat(long amount, byte decimalPlaces, string value) { Amount = amount; Symbol = new AssetSymbolType(decimalPlaces, value); }
public Asset(long amount, uint assetNum) { Amount = amount; Symbol = new AssetSymbolType(assetNum); }