static void Main(string[] args) { #region Patterns //factory patterns RunSimpleFactory(); RunAbstrctMethodFactory(); //Singleton pattern RunSingleton(); #endregion #region StructVSClass //Struct vs Class TestStruct testStruct = new TestStruct(); TestClass testClass = new TestClass(); testStruct.x = 1; testClass.x = 1; StructTest.TakeClass(testClass); StructTest.TakeStruct(testStruct); Console.WriteLine(); Console.WriteLine("TestClass = {0} TestStruct = {1}", testClass.x, testStruct.x); #endregion #region index test //indexer test MyArray myTestArray = new MyArray(); for (int i = 0; i < 10; i++) { Console.WriteLine(myTestArray[i]); } for (int i = 0; i < 10 / 2; i++) { string s = myTestArray[i]; myTestArray[i] = myTestArray[myTestArray.Length() - i - 1]; myTestArray[myTestArray.Length() - i - 1] = s; } for (int i = 0; i < 10; i++) { Console.WriteLine(myTestArray[i]); } #endregion #region BookTest var bookProcesser = new BookProcessor(); DBEventListener dbBookListener = new DBEventListener(bookProcesser.GetBookDb()); PopulateBookProcessor(bookProcesser); string choice = string.Empty; do { choice = bookProcesser.BuyBook(new BookProcessor.OutOfStockDelegate(ProcessOutofStock)); } while (choice != "q"); #endregion BookTest #region FacadeTest Customer customerOne = new Customer("Bob Jones", 150000); Customer customerTwo = new Customer("Sally Smith", 90000); MortgageApprover mortgageApprove = new MortgageApprover(); Console.WriteLine( mortgageApprove.CheckForApproval(customerOne) ? "Customer {0} is approved!" : "Custerom {0} is declined :(", customerOne.Name); Console.WriteLine( mortgageApprove.CheckForApproval(customerTwo) ? "Customer {0} is approved!" : "Custerom {0} is declined :(", customerTwo.Name); #endregion #region AdapterTest AdapterPattern adapterTest = new AdapterPattern(); adapterTest.TestAdapterPattern(); #endregion }