private static List <IDiscountPrice> getDiscountList() { List <IDiscountPrice> list = new List <IDiscountPrice>(); IEnumerable <Type> theList = Assembly.GetExecutingAssembly().GetTypes() .Where(t => t.Namespace == typeof(IDiscountPrice).Namespace && !t.IsAbstract && t.GetInterfaces().Contains(typeof(IDiscountPrice))); foreach (var item in theList) { IDiscountPrice obj = Activator.CreateInstance(item) as IDiscountPrice; if (obj != null) { list.Add(obj); } } return(list); }
public OrderDTO procOrder(OrderDTO orderinfo) { int totalAmount = orderinfo.items .Select(item => item.quanity * item.unitPrice) .Sum(); IDiscountPrice d = DiscountFactory.getDiscount(orderinfo.discount, totalAmount); if (d != null) { orderinfo.TotalPrice = d.calcTotalAmountbyDiscount(orderinfo.discount, totalAmount); } else { orderinfo.TotalPrice = totalAmount; } return(orderinfo); }