コード例 #1
0
        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();
        }
コード例 #2
0
        public Product(string name = null, double price = 0.0, IVat vat = null)
        {
            Id    = Count++;
            Name  = name ?? RandomProductNameGenerator.Generate();
            Price = price;

            Vat = vat ?? new Vat();
        }
コード例 #3
0
        // 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);
        }
コード例 #4
0
 public void AddVat(IVat vat)
 {
     m_vats.Add(vat);
 }
コード例 #5
0
 public void RemoveVat(IVat vat)
 {
     m_vats.Remove(vat);
 }
コード例 #6
0
 // 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();
 }
コード例 #7
0
 // Create a product
 public static IProduct CreateNew(int priceRange = 100, IVat vat = null, ICompany store = null)
 {
     throw new NotImplementedException();
 }
コード例 #8
0
        // 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);
        }