예제 #1
0
    /// <summary>
    /// Removes a TradbaleAsset from this class.
    /// </summary>
    /// <param name="address"> The address of the asset to remove. </param>
    public void RemoveTradableAsset(string address)
    {
        if (!TradableAssets.ContainsKey(address))
        {
            return;
        }

        var tradableAsset = TradableAssets[address];

        TradableAssets.Remove(address);
        tradableAsset.OnAssetBalanceChanged -= _ => OnBalancesUpdated?.Invoke();

        OnTradableAssetRemoved?.Invoke(tradableAsset);
    }
예제 #2
0
    /// <summary>
    /// Adds a new asset to the collection of TradableAssets to manage.
    /// </summary>
    /// <param name="tradableAsset"> The TradableAsset to add to the manager. </param>
    public void AddTradableAsset(TradableAsset tradableAsset)
    {
        var address = tradableAsset.AssetAddress;

        if (TradableAssets.ContainsKey(address))
        {
            return;
        }

        if (tradableAsset is EtherAsset)
        {
            EtherAsset = tradableAsset as EtherAsset;
            SetNewActiveAsset(tradableAsset);
        }

        TradableAssets.Add(address, tradableAsset);
        tradableAsset.OnAssetBalanceChanged += _ => OnBalancesUpdated?.Invoke();

        OnTradableAssetAdded?.Invoke(tradableAsset);
    }
예제 #3
0
 /// <summary>
 /// Sets a new active asset given a TradableAsset.
 /// Active asset is determined based on which button was selected.
 /// </summary>
 /// <param name="tradableAsset"> The new TradableAsset ot be our active asset. </param>
 public void SetNewActiveAsset(TradableAsset tradableAsset)
 {
     ActiveTradableAsset = tradableAsset;
     OnBalancesUpdated?.Invoke();
 }