comparison Implab.Playground/Program.cs @ 267:6b3e5c48131b v3

Working on Unity xml configuration
author cin
date Fri, 20 Apr 2018 19:05:12 +0300
parents 547a2fc0d93e
children 0be8a6ae8307
comparison
equal deleted inserted replaced
266:254d1f255d87 267:6b3e5c48131b
1 using Implab.Diagnostics; 1 using System;
2 using Implab.Formats.Json; 2 using Implab.ServiceHost.Unity;
3 using Implab.Parallels;
4 using Implab.Xml; 3 using Implab.Xml;
5 using System; 4 using Unity;
6 using System.Collections.Concurrent; 5 using Unity.Injection;
7 using System.Collections.Generic;
8 using System.IO;
9 using System.Linq;
10 using System.Text;
11 using System.Threading;
12 using System.Threading.Tasks;
13 using System.Xml;
14 using System.Xml.Serialization;
15 6
16 namespace Implab.Playground { 7 namespace Implab.Playground {
17 using System.Diagnostics; 8
18 using static Trace<Program>; 9 public class Foo {
10 public int IntValue { get; set; }
11
12 public string StringValue { get; set; }
13
14 }
15
16 public class Container<T> {
17 public Container() {
18
19 }
20
21 public Container(T instance) {
22 Instance = instance;
23 }
24
25 public T Instance { get; set; }
26 }
19 27
20 public class Program { 28 public class Program {
21 29
22 static void Main(string[] args) { 30 static void Main(string[] args) {
23 var listener = new SimpleTraceListener(Console.Out); 31 var container = new UnityContainer();
24 32
25 var source = Trace<Program>.TraceSource; 33 var containerConfig = SerializationHelpers.DeserializeFromFile<ContainerElement>("data/sample.xml");
26 source.Switch.Level = SourceLevels.All;
27 34
28 source.Listeners.Add(listener); 35 Console.WriteLine($"container: {containerConfig.Registrations.Count}");
29
30 var t = Environment.TickCount;
31
32 Main().Wait();
33
34 Console.WriteLine($"Done: {Environment.TickCount - t} ms");
35 Console.ReadKey();
36 } 36 }
37 37
38 static async Task Main() {
39 using (LogicalOperation(nameof(Main))) {
40 Log("Start");
41 await SomeAsync();
42 Log("End");
43 }
44 }
45 38
46 static async Task SomeAsync() {
47 using (LogicalOperation(nameof(SomeAsync))) {
48 Log("Do prepare");
49 await Task.Yield();
50 Log("Yield");
51 }
52 }
53 } 39 }
54 } 40 }