Example #1
0
        public virtual object Clone()
        {
            var clonedObj = new Media();
              clonedObj.Id = this.Id;
              clonedObj.Price = this.Price;
              clonedObj.Title = this.Title;

              return clonedObj;
        }
Example #2
0
        public void AddToShoppingCart(Media item, int copies)
        {
            if (item == null)
            throw new ArgumentNullException("item");
              if (copies <= 0)
            throw new ArgumentOutOfRangeException("copeis");

              for (int i = 0; i < copies; i++)
              {
            //First copy doesn't need to be cloned
            if (i == 0)
              this.Items.Add(item);
            else
            {
              var cloned = item.Clone();
              ((Media)cloned).Id = Guid.NewGuid();
              this.Items.Add(cloned as Media);
            }
              }
        }