Пример #1
0
 /// <summary>
 /// Return the List of
 /// <see cref="GCheckout.AutoGen.ItemShippingInformation"/>[]
 /// </summary>
 public AutoGen.ItemShippingInformation[] ToArray()
 {
     AutoGen.ItemShippingInformation[] retVal
         = new AutoGen.ItemShippingInformation[_items.Count];
     _items.Values.CopyTo(retVal, 0);
     return(retVal);
 }
Пример #2
0
        private void AppendTracking(AutoGen.ItemShippingInformation item)
        {
            if (item.trackingdatalist == null)
            {
                item.trackingdatalist = new AutoGen.TrackingData[] { }
            }
            ;

            AutoGen.TrackingData[] newList
                = new GCheckout.AutoGen.TrackingData[item.trackingdatalist.Length + 1];

            if (item.trackingdatalist.Length > 0)
            {
                Array.Copy(item.trackingdatalist, 0,
                           newList, 0, item.trackingdatalist.Length);
            }

            newList[newList.Length - 1] = _tracking;
            item.trackingdatalist       = newList;
        }
Пример #3
0
        /// <summary>
        /// The &lt;merchant-item-id&gt; tag contains a value,
        /// such as a stock keeping unit (SKU),
        /// that you use to uniquely identify an item.
        /// </summary>
        /// <param name="itemID">The item to add to the box</param>
        public void AddMerchantItemID(string itemID)
        {
            if (itemID == null || itemID.Length == 0)
            {
                throw new ArgumentException("itemID must be valid length > 0.");
            }

            AutoGen.ItemShippingInformation[] items
                = new AutoGen.ItemShippingInformation[_items.Count];
            _items.CopyTo(items, 0);

            for (int i = 0; i < items.Length; i++)
            {
                if (items[i].itemid.merchantitemid == itemID)
                {
                    throw new ApplicationException(
                              "Duplicate MerchantItemID added to the box'" + itemID + "'.");
                }
            }

            //The hash starts with G for google items and M for merchant items
            AutoGen.ItemShippingInformation item = null;

            string key = "M:" + itemID;

            if (!_lookup.TryGetValue(key, out item))
            {
                item = new AutoGen.ItemShippingInformation();

                AutoGen.ItemId lineItem = new GCheckout.AutoGen.ItemId();
                lineItem.merchantitemid = itemID;
                item.itemid             = lineItem;

                _lookup[key] = item;
            }
            AppendTracking(item);
            _items.Add(item);
        }
        /// <summary>
        /// The &lt;merchant-item-id&gt; tag contains a value, 
        /// such as a stock keeping unit (SKU), 
        /// that you use to uniquely identify an item.
        /// </summary>
        /// <param name="itemID">The item to add to the box</param>
        public void AddMerchantItemID(string itemID)
        {
            if (itemID == null || itemID.Length == 0)
            throw new ArgumentException("itemID must be valid length > 0.");

              AutoGen.ItemShippingInformation[] items
            = new AutoGen.ItemShippingInformation[_items.Count];
              _items.CopyTo(items, 0);

              for (int i = 0; i < items.Length; i++) {
            if (items[i].itemid.merchantitemid == itemID) {
              throw new ApplicationException(
            "Duplicate MerchantItemID added to the box'" + itemID + "'.");
            }
              }

              //The hash starts with G for google items and M for merchant items
              AutoGen.ItemShippingInformation item = null;

              string key = "M:" + itemID;

              if (!_lookup.TryGetValue(key, out item)) {

            item = new AutoGen.ItemShippingInformation();

            AutoGen.ItemId lineItem = new GCheckout.AutoGen.ItemId();
            lineItem.merchantitemid = itemID;
            item.itemid = lineItem;

            _lookup[key] = item;
              }
              AppendTracking(item);
              _items.Add(item);
        }