diff Implab.Playground/Program.cs @ 279:8714471e8d78 v3

Container configuration cleanup, RC2
author cin
date Fri, 04 May 2018 18:12:42 +0300
parents 6691aff01de1
children f07be402ab02
line wrap: on
line diff
--- a/Implab.Playground/Program.cs	Thu May 03 09:59:44 2018 +0300
+++ b/Implab.Playground/Program.cs	Fri May 04 18:12:42 2018 +0300
@@ -94,22 +94,27 @@
             source.Switch.Level = SourceLevels.All;
             source.Listeners.Add(listener);
 
-            var resolver = new TypeResolver();
-            resolver.AddNamespace("System");
-            resolver.AddNamespace("System.Collections.Generic");
-            resolver.AddNamespace("Implab.Playground");
-            resolver.AddMapping("string", typeof(string));
-            resolver.AddMapping("listOf`1", typeof(List<>));
+            var stopwatch = new Stopwatch();
+            stopwatch.Start();
+
+            var container = new UnityContainer();
+
+            Console.WriteLine($"Created: {stopwatch.ElapsedMilliseconds}");
+            stopwatch.Restart();
+            
+            container.LoadXmlConfiguration("data/sample.xml");
 
-            var spec = TypeReference.Parse("Container{listOf{string}}+Bar{List{string}}");
+            Console.WriteLine($"Loaded: {stopwatch.ElapsedMilliseconds}");
 
-            var t = resolver.Resolve(spec, true);
+            stopwatch.Restart();
+            var instace1 = container.Resolve<IContainer<string>>();
+            Console.WriteLine($"Resolved1: {stopwatch.ElapsedMilliseconds}");
 
-            Console.WriteLine("{0}", t);
-            Console.WriteLine("Spec: {0}", spec);
-            Console.WriteLine("IsGenericType: {0}", t.IsGenericType);
-            Console.WriteLine("IsGenericTypeDefinition: {0}", t.IsGenericTypeDefinition);
-            Console.WriteLine("ContainsGenericParameters: {0}", t.ContainsGenericParameters);
+            stopwatch.Restart();
+            var instace2 = container.Resolve<IContainer<Foo>>();
+            Console.WriteLine($"Resolved2: {stopwatch.ElapsedMilliseconds}");
+
+            DisplayContainerRegistrations(container);
         }
 
         static void DisplayContainerRegistrations(IUnityContainer theContainer) {