Ejemplo n.º 1
0
    /// <summary>
    /// Disposes of the loaded TradableAssets.
    /// </summary>
    public void Dispose()
    {
        TradableAssets.Clear();

        ActiveTradableAsset = null;
        EtherAsset          = null;
    }
Ejemplo n.º 2
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);
    }
Ejemplo n.º 3
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);
    }
Ejemplo n.º 4
0
 /// <summary>
 /// Gets a TradableAsset given its address.
 /// </summary>
 /// <param name="address"> The address of the asset to receive. </param>
 /// <returns> The TradableAsset located at the address. </returns>
 public TradableAsset GetTradableAsset(string address) => TradableAssets.ContainsKey(address) ? TradableAssets[address] : null;