internal static Product ConvertToXamProduct(iOSBinding.MPProduct product) { { if (product == null) { return(null); } var customKeys = product.AllKeys.ToDictionary(key => key.ToString(), key => product.ObjectForKeyedSubscript(key.ToString()).ToString()); return(new Product(product.Name, product.Sku, product.UnitPrice, product.Quantity.DoubleValue) { Brand = product.Brand, CouponCode = product.CouponCode, Position = Convert.ToInt32(product.Position), Category = product.Category, Variant = product.Variant, customAttributes = customKeys }); } }
internal static iOSBinding.MPProduct ConvertToMpProduct(Product product) { var bindingProduct = new iOSBinding.MPProduct(); bindingProduct.Sku = product.Sku; bindingProduct.Name = product.Name; bindingProduct.UnitPrice = product.Price; bindingProduct.Quantity = new NSNumber(product.Quantity); bindingProduct.Brand = product.Brand; bindingProduct.Category = product.Category; bindingProduct.CouponCode = product.CouponCode; bindingProduct.Variant = product.Variant; if (product.customAttributes != null) { foreach (var kvp in product.customAttributes) { bindingProduct.SetObject((NSObject) new NSString(kvp.Value), new NSString(kvp.Key)); } } return(bindingProduct); }