コード例 #1
0
        private static IReadOnlyList <PaymentShippingOption> CreateShippingOptions(ShoppingCart shoppingCart)
        {
            List <PaymentShippingOption> paymentShippingOptions = new List <PaymentShippingOption>();

            ShippingType selectedShippingType = shoppingCart.ShippingType;
            IReadOnlyDictionary <ShippingType, ShoppingCartCostsSummary> cartShippingOptions = shoppingCart.CalculateShippingOptions();

            ShoppingCartCostsSummary costsOfSelectedShipping = cartShippingOptions[selectedShippingType];

            foreach (var kvp in cartShippingOptions)
            {
                ShippingType             shippingType = kvp.Key;
                ShoppingCartCostsSummary costs        = kvp.Value;

                PaymentShippingOption shippingOption = new PaymentShippingOption(
                    label: ShippingTypeStringUtilities.CreateShippingOptionTitle(shippingType, costs, costsOfSelectedShipping),
                    selected: (shippingType == selectedShippingType),
                    tag: shippingType.ToString(),
                    amount: CreateCurrencyAmount(costs.Shipping));

                paymentShippingOptions.Add(shippingOption);
            }

            return(paymentShippingOptions);
        }
コード例 #2
0
        /// <summary>
        /// Get the Name for the Enum Value
        /// </summary>
        /// <param name="shippingType">The ShippingType Value</param>
        /// <returns></returns>
        public static string GetSerializedName(ShippingType shippingType)
        {
            FieldInfo fi = t.GetField(shippingType.ToString());

            return(EnumSerilizedNameAttribute.GetValue(fi));
        }
コード例 #3
0
 /// <summary>
 /// Get the Shipping Comany Name for an Enum Value
 /// </summary>
 /// <param name="shippingType">The ShippingType Value</param>
 /// <returns></returns>
 public static string GetShippingCompany(ShippingType shippingType)
 {
     FieldInfo fi = t.GetField(shippingType.ToString());
       return TypeDictionaryEntryAttribute.GetValue(fi, "shipping-company");
 }
コード例 #4
0
        /// <summary>
        /// Get the Shipping Comany Name for an Enum Value
        /// </summary>
        /// <param name="shippingType">The ShippingType Value</param>
        /// <returns></returns>
        public static string GetShippingCompany(ShippingType shippingType)
        {
            FieldInfo fi = t.GetField(shippingType.ToString());

            return(TypeDictionaryEntryAttribute.GetValue(fi, "shipping-company"));
        }
コード例 #5
0
 /// <summary>
 /// Get the Name for the Enum Value
 /// </summary>
 /// <param name="shippingType">The ShippingType Value</param>
 /// <returns></returns>
 public static string GetSerializedName(ShippingType shippingType)
 {
     FieldInfo fi = t.GetField(shippingType.ToString());
       return EnumSerilizedNameAttribute.GetValue(fi);
 }