Beispiel #1
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);
        }
        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);
            }
            PaymentTypes type = PaymentTypes.BTCLike;

            if (parts.Length == 2)
            {
                var typePart = parts[1].ToLowerInvariant();
                switch (typePart)
                {
                case "btclike":
                case "onchain":
                    type = PaymentTypes.BTCLike;
                    break;

                case "lightninglike":
                case "offchain":
                    type = PaymentTypes.LightningLike;
                    break;

                default:
                    if (!Enum.TryParse(typePart, true, out type))
                    {
                        return(false);
                    }

                    break;
                }
            }
            paymentMethodId = new PaymentMethodId(parts[0], type);
            return(true);
        }