comparison Implab.Playground/Program.cs @ 273:79110a16cab7 v3

Working on Unity xml configuration: Refactoring in progress
author cin
date Thu, 26 Apr 2018 19:35:01 +0300
parents 9d1cca834b05
children 22629bf26121
comparison
equal deleted inserted replaced
272:9d1cca834b05 273:79110a16cab7
45 } 45 }
46 46
47 public class Program { 47 public class Program {
48 48
49 static void Main(string[] args) { 49 static void Main(string[] args) {
50 var container = new UnityContainer(); 50 var stopwatch = new Stopwatch();
51 stopwatch.Start();
51 52
52 var ctx = new ConfigurationContext(container); 53 var ctx = new ContainerContext();
53 54
54 var conf = SerializationHelpers.DeserializeFromFile<ContainerElement>("data/sample.xml"); 55 Console.WriteLine($"Created: {stopwatch.ElapsedMilliseconds}");
55 56
56 ctx.Visit(conf); 57 ctx.LoadConfig("data/sample.xml");
58
59 Console.WriteLine($"Loaded: {stopwatch.ElapsedMilliseconds}");
60
61 var container = ctx.Container;
62
63
64
65 var instace1 = container.Resolve<IContainer<string>>();
66 Console.WriteLine($"Resolved1: {stopwatch.ElapsedMilliseconds}");
67 var instace2 = container.Resolve<IContainer<Foo>>();
68
69 Console.WriteLine($"Resolved2: {stopwatch.ElapsedMilliseconds}");
57 70
58 DisplayContainerRegistrations(container); 71 DisplayContainerRegistrations(container);
59
60 var instace1 = container.Resolve<IContainer<string>>();
61 var instace2 = container.Resolve<IContainer<Foo>>();
62
63 } 72 }
64 73
65 static void DisplayContainerRegistrations(IUnityContainer theContainer) { 74 static void DisplayContainerRegistrations(IUnityContainer theContainer) {
66 string regName, regType, mapTo, lifetime; 75 string regName, regType, mapTo, lifetime;
67 Console.WriteLine("Container has {0} Registrations:", 76 Console.WriteLine("Container has {0} Registrations:",