Example #1
0
        public static string ToRemoteCode(this Asset asset, IDescribesAssets provider)
        {
            if (provider == null)
            {
                throw new ArgumentException(nameof(provider));
            }

            var cv = provider.GetAssetCodeConverter();

            if (cv == null)
            {
                return(asset.ShortCode);
            }

            return(ToRemoteCode(asset, cv));
        }
Example #2
0
        public static Asset ToAsset(this string assetCode, IDescribesAssets provider)
        {
            if (provider == null)
            {
                throw new ArgumentException(nameof(provider));
            }

            var cv = provider.GetAssetCodeConverter();

            if (cv == null)
            {
                return(Assets.I.Get(assetCode, provider));
            }

            return(Assets.I.Get(cv.ToLocalCode(assetCode), provider));
        }
Example #3
0
        public Asset Get(string assetCode, IDescribesAssets provider)
        {
            if (string.IsNullOrWhiteSpace(assetCode))
            {
                return(Asset.None);
            }

            if (provider == null)
            {
                throw new ArgumentException(nameof(provider));
            }

            var cv = provider.GetAssetCodeConverter();

            if (cv == null)
            {
                return(GetRaw(assetCode));
            }

            assetCode = cv.ToLocalCode(assetCode);

            return(_cache.GetOrAdd(assetCode, Asset.InstanceRaw));
        }