forked from phatboyg/Magnum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcsharp.functions
85 lines (73 loc) · 2.52 KB
/
csharp.functions
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?xml version="1.0" encoding="utf-8" ?>
<project name="BuildSettings">
<script language="C#" >
<references>
<include name="System.dll" />
</references>
<imports>
<import namespace="System" />
<import namespace="System.Diagnostics" />
<import namespace="System.IO" />
<import namespace="System.Reflection" />
<import namespace="Nant.Core" />
<import namespace="Nant.Core.Attributes" />
</imports>
<code>
<![CDATA[
[TaskName("results")]
public class ResultsProcessTask : Task
{
private string _display;
[TaskAttribute("display", Required = true)]
public string Display
{
get { return _display; }
set { _display = value; }
}
protected override void ExecuteTask()
{
if (platformIsWindows())
ExecuteProcess(CombinePaths(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles),"Internet Explorer","iexplore.exe"), Display);
else
ExecuteProcess(Display);
}
protected string CombinePaths(params string[] paths)
{
string combinedPath = string.Empty;
foreach (string path in paths)
{
combinedPath = Path.Combine(combinedPath, path);
}
return combinedPath;
}
protected void ExecuteProcess(string file)
{
ProcessStartInfo psi = new ProcessStartInfo(file, "");
using (Process p = new Process())
{
p.StartInfo = psi;
p.Start();
}
}
protected void ExecuteProcess(string process, string arguments)
{
ProcessStartInfo psi = new ProcessStartInfo(Path.GetFullPath(process), arguments);
psi.UseShellExecute = false;
psi.RedirectStandardOutput = false;
psi.CreateNoWindow = false;
using (Process p = new Process())
{
p.StartInfo = psi;
p.Start();
}
}
protected bool platformIsWindows()
{
PlatformID platform = Environment.OSVersion.Platform;
return !(platform.Equals(PlatformID.Unix) || platform.Equals(PlatformID.MacOSX));
}
}
]]>
</code>
</script>
</project>