/examples/ioc/CarLibrary4/Car.cs
C# | 46 lines | 39 code | 7 blank | 0 comment | 8 complexity | 1ab8a6631aa280a42c31573fca367618 MD5 | raw file
1using System; 2using System.Collections.Generic; 3using System.Text; 4using CarLibrary3; 5 6using LinFu.IoC; 7using LinFu.IoC.Configuration; 8using LinFu.IoC.Interfaces; 9 10namespace CarLibrary3 11{ 12 public class Car : IVehicle 13 { 14 private IEngine _engine; 15 private IPerson _person; 16 17 18 public IEngine Engine 19 { 20 get { return _engine; } 21 set { _engine = value; } 22 } 23 public IPerson Driver 24 { 25 get { return _person; } 26 set { _person = value; } 27 } 28 public void Move() 29 { 30 if (_engine == null || _person == null) 31 return; 32 33 _engine.Start(); 34 Console.WriteLine("{0} says: I�m moving!", _person.Name); 35 } 36 public void Park() 37 { 38 if (_engine == null || _person == null) 39 return; 40 41 _engine.Stop(); 42 Console.WriteLine("{0} says: I�m parked!", _person.Name); 43 } 44 } 45 46}