Beispiel #1
0
        static void Main(string[] args)
        {
            HelloService    helloService    = new HelloService();
            ConsumerService consumerService = new ConsumerService(helloService);

            consumerService.Print();

            Console.ReadKey();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            HelloService    helloService    = (HelloService)Activator.CreateInstance(typeof(HelloService));                     //动态创建对象HelloService
            ConsumerService consumerService = (ConsumerService)Activator.CreateInstance(typeof(ConsumerService), helloService); //动态创建对象ConsumerService

            consumerService.Print();

            Console.ReadKey();
        }
Beispiel #3
0
 public ConsumerService(HelloService helloService)
 {
     this._helloService = helloService;
 }