static void Main(string[] args) { Console.Title = "Object Oriented Design Assignment 7: Adapter Pattern"; Console.WindowHeight = 30; Console.WindowWidth = 50; //Create Language objects: HumanLanguage English = new English(); HumanLanguage French = new French(); HumanLanguage Spanish = new Spanish(); MachineLanguage Binary = new Binary(); //This is the adapter for the binary language: HumanLanguage BinaryAdapter = new BinaryAdapter(Binary); Console.WriteLine("*************************************"); Console.WriteLine("*************************************"); Console.WriteLine("* Welcome to the Speech Simulator *"); Console.WriteLine("* Listed below are the words for *"); Console.WriteLine("* 'Hello' in various languages *"); Console.WriteLine("*************************************"); Console.WriteLine("*************************************"); Console.WriteLine(); //Print out hello in each language Console.WriteLine("English: "); English.sayHello(); Console.WriteLine(); Console.WriteLine("French: "); French.sayHello(); Console.WriteLine(); Console.WriteLine("Spanish: "); Spanish.sayHello(); Console.WriteLine(); //The adapter makes it possible for the binary object to sayHello: Console.WriteLine("Machine: "); BinaryAdapter.sayHello(); Console.ReadKey(); }
public T Load <T>(string path) { return(BinaryAdapter.Deserialize <T>(FileAdapter.ReadAllBytes(_defaultPath + path))); }
public void Save <T>(string path, T obj) { FileAdapter.WriteAllBytes(_defaultPath + path, BinaryAdapter.Serialize(obj)); }