Exemple #1
0
        static void Main(string[] args)
        {
            var cellphoneFactory = ConfigurationManager.AppSettings["CellphoneFactory"];
            var dllName          = ConfigurationManager.AppSettings["DllName"];
            var currentAssembly  = Assembly.GetExecutingAssembly();
            var codeBase         = currentAssembly.CodeBase.ToLower().Replace(currentAssembly.ManifestModule.Name.ToLower(), string.Empty);

            var            factoryAssembly = Assembly.LoadFrom(Path.Combine(codeBase, dllName));
            ProductFactory productFactory  = factoryAssembly.CreateInstance(cellphoneFactory) as ProductFactory;
            Cellphone      cellphone       = productFactory.CreateCellphone();
            UI             ui = productFactory.CreateUI();

            cellphone.WrapUI(ui);

            Console.Read();
        }