Exemplo n.º 1
0
        static void Main()
        {
            Assembly assembly = null;

            try
            {
                assembly = Assembly.Load("CarLibrary");
                Type type = assembly.GetType("CarLibrary.MiniVan");

                dynamic carInstance = Activator.CreateInstance(type);
                carInstance.Acceleration();
                carInstance.Driver("Shumaher", 26);
            }
            catch (FileNotFoundException e)
            {
                Console.WriteLine(e.Message);
            }

            // Delay.
            Console.ReadKey();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Assembly assembly = null;

            try
            {
                assembly = Assembly.Load("001_CarLibrary");
                Type type = assembly.GetType("_001_CarLibrary.MiniVan");

                //Т.е можно через dynamic вызвать методы, а можно через MethodInfo как в примере 002_LateBuildingObject
                dynamic miniVanInstance = Activator.CreateInstance(type);
                miniVanInstance.Acceleration();
                miniVanInstance.Driver("Vasya", 55);
            }
            catch (FileNotFoundException e)
            {
                Console.WriteLine(e.Message);
            }

            //Delay
            Console.ReadKey();
        }