PageRenderTime 4ms CodeModel.GetById 1ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

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