1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace PetStore
.Web
.Controllers
.State
18 using System
.Collections
;
21 /// Session state pattern to hold the
25 public class CartState
: IEnumerable
27 private IList items
= new ArrayList();
29 public void Add(int quantity
, int productId
)
31 items
.Add(new CartItem(quantity
, productId
));
34 public void Remove(CartItem item
)
46 private readonly int quantity
;
47 private readonly int productId
;
49 public CartItem(int quantity
, int productId
)
51 this.quantity
= quantity
;
52 this.productId
= productId
;
57 get { return quantity; }
62 get { return productId; }
66 #region IEnumerable Members
68 public IEnumerator
GetEnumerator()
70 return items
.GetEnumerator();