/examples/ioc/PropertyInjectionSample/Program.cs

http://github.com/philiplaureano/LinFu · C# · 37 lines · 27 code · 8 blank · 2 comment · 0 complexity · d4cc87cf77c3a2d3d6a378a62cda3984 MD5 · raw file

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using CarLibrary2;
  5. using LinFu.IoC;
  6. using LinFu.IoC.Configuration;
  7. using LinFu.IoC.Interfaces;
  8. namespace PropertyInjectionSample
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. string directory = AppDomain.CurrentDomain.BaseDirectory;
  15. IServiceContainer container = new ServiceContainer();
  16. // Load CarLibrary2.dll; If you need load
  17. // all the libaries in a directory, use "*.dll" instead
  18. container.LoadFrom(directory, "CarLibrary2.dll");
  19. Person person = new Person();
  20. person.Name = "Someone";
  21. person.Age = 18;
  22. container.AddService<IPerson>(person);
  23. IVehicle vehicle = container.GetService<IVehicle>();
  24. vehicle.Move();
  25. Console.WriteLine("Press ENTER to continue...");
  26. Console.ReadLine();
  27. }
  28. }
  29. }