/examples/ioc/CarLibrary4/Car.cs

http://github.com/philiplaureano/LinFu · C# · 46 lines · 39 code · 7 blank · 0 comment · 8 complexity · 1ab8a6631aa280a42c31573fca367618 MD5 · raw file

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using CarLibrary3;
  5. using LinFu.IoC;
  6. using LinFu.IoC.Configuration;
  7. using LinFu.IoC.Interfaces;
  8. namespace CarLibrary3
  9. {
  10. public class Car : IVehicle
  11. {
  12. private IEngine _engine;
  13. private IPerson _person;
  14. public IEngine Engine
  15. {
  16. get { return _engine; }
  17. set { _engine = value; }
  18. }
  19. public IPerson Driver
  20. {
  21. get { return _person; }
  22. set { _person = value; }
  23. }
  24. public void Move()
  25. {
  26. if (_engine == null || _person == null)
  27. return;
  28. _engine.Start();
  29. Console.WriteLine("{0} says: I’m moving!", _person.Name);
  30. }
  31. public void Park()
  32. {
  33. if (_engine == null || _person == null)
  34. return;
  35. _engine.Stop();
  36. Console.WriteLine("{0} says: I’m parked!", _person.Name);
  37. }
  38. }
  39. }