Esempio n. 1
0
        public static bool TryParse(string?str, [MaybeNullWhen(false)] out PaymentMethodId paymentMethodId)
        {
            str ??= "";
            paymentMethodId = null;
            var parts = str.Split(Separators, StringSplitOptions.RemoveEmptyEntries);

            if (parts.Length == 0 || parts.Length > 2)
            {
                return(false);
            }
            PaymentType type = PaymentTypes.BTCLike;

#if ALTCOINS
            if (parts[0].ToUpperInvariant() == "XMR")
            {
                type = PaymentTypes.MoneroLike;
            }
            if (parts[0].ToUpperInvariant() == "ZEC")
            {
                type = PaymentTypes.ZcashLike;
            }
#endif
            if (parts.Length == 2)
            {
                if (!PaymentTypes.TryParse(parts[1], out type))
                {
                    return(false);
                }
            }
            paymentMethodId = new PaymentMethodId(parts[0], type);
            return(true);
        }
Esempio n. 2
0
        public static bool TryParse(string str, out PaymentMethodId paymentMethodId)
        {
            paymentMethodId = null;
            var parts = str.Split('_', StringSplitOptions.RemoveEmptyEntries);

            if (parts.Length == 0 || parts.Length > 2)
            {
                return(false);
            }
            PaymentType type = PaymentTypes.BTCLike;

            if (parts.Length == 2)
            {
                if (!PaymentTypes.TryParse(parts[1], out type))
                {
                    return(false);
                }
            }
            paymentMethodId = new PaymentMethodId(parts[0], type);
            return(true);
        }