forked from OpenCoverUI/OpenCover.UI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
60 lines (53 loc) · 1.24 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//
// This source code is released under the MIT License; Please read license.md file for more details.
//
using System;
using System.IO;
using System.IO.Pipes;
using System.Linq;
using System.Web.Script.Serialization;
namespace OpenCover.UI.TestDiscoverer
{
class Program
{
static void Main(string[] args)
{
try
{
if (args.Length > 1)
{
NamedPipeClientStream pipeClient = new NamedPipeClientStream(".", args[0], PipeDirection.InOut);
pipeClient.Connect();
Discover(args, pipeClient);
pipeClient.WaitForPipeDrain();
pipeClient.Close();
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
private static void Discover(string[] args, NamedPipeClientStream stream)
{
if (args != null && args.Length > 0)
{
var dlls = args.Skip(1);
var tests = new Discoverer(dlls).Discover();
string serialized = String.Empty;
if (tests != null)
{
var jsSerializer = new JavaScriptSerializer();
serialized = jsSerializer.Serialize(tests);
}
Write(stream, serialized);
}
}
private static void Write(Stream stream, string json)
{
var writer = new StreamWriter(stream);
writer.Write(json);
writer.Flush();
}
}
}