private static void RunMultipleImplementationExample() { foreach (Country country in Enum.GetValues(typeof(Country))) { double import = 1000; Console.WriteLine(); Console.WriteLine(string.Format("Creating Vat instance for {0}", country)); IVat vatImplementation = Resolver.Resolve <IVat>(country); vatImplementation.Init(); Console.WriteLine("Vat instance initialized."); Console.WriteLine(string.Format("Vat country: {0}", vatImplementation.Country)); Console.WriteLine(string.Format("Original import:{0}", import)); Console.WriteLine(string.Format("Vat percentage initially applied: {0}", vatImplementation.VatPercentage)); Console.WriteLine(String.Format("Import after VAT: {0}", vatImplementation.ApplyVatTo(import))); double originalPercentage = vatImplementation.VatPercentage; vatImplementation.VatPercentage += 3; Console.WriteLine(string.Format("Vat percentage changed from {0} to {1}", originalPercentage, vatImplementation.VatPercentage)); Console.WriteLine(String.Format("Import after VAT: {0}", vatImplementation.ApplyVatTo(import))); Console.WriteLine(); } AddSeparator(); }
public Product(string name = null, double price = 0.0, IVat vat = null) { Id = Count++; Name = name ?? RandomProductNameGenerator.Generate(); Price = price; Vat = vat ?? new Vat(); }
// Create a product public static IProduct CreateNew(int priceRange = 100, IVat vat = null, ICompany store = null) { String productName = RandomProductNameGenerator.Generate(); int productPrice = _random.Next(1, priceRange); var product = new Product(productName, productPrice, vat); if (store != null) { product.Company = store; } return(product); }
public void AddVat(IVat vat) { m_vats.Add(vat); }
public void RemoveVat(IVat vat) { m_vats.Remove(vat); }
// Create multiple products at once public static List <IProduct> CreateMultipleProducts(int count, int priceRange = 100, IVat vat = null, IManager manager = null, ICompany store = null) { throw new NotImplementedException(); }
// Create a product public static IProduct CreateNew(int priceRange = 100, IVat vat = null, ICompany store = null) { throw new NotImplementedException(); }
// Create multiple products at once public static List <IProduct> CreateMultipleProducts(int count, int priceRange = 100, IVat vat = null, IManager manager = null, ICompany store = null) { List <IProduct> products = new List <IProduct>(); if (manager != null) { if (store == null && manager.GetCompanies().Count > 0) { store = manager.getRandomCompany(); } } int iteration = 0; while (iteration < count) { products.Add(CreateNew(priceRange, vat, store)); iteration++; } return(products); }