-
Notifications
You must be signed in to change notification settings - Fork 1
/
TfsCliHelper.cs
51 lines (46 loc) · 1.7 KB
/
TfsCliHelper.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
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
namespace tfs_cli
{
class TfsCliHelper
{
private static TraceSwitch _logger = new TraceSwitch("tfs_cli", "tfs_cli log", TraceLevel.Error.ToString());
public static void ExitWithError(string message)
{
Trace.WriteLine(message);
Console.WriteLine(message);
Environment.Exit(1);
}
public static string fromHtml(string htmlText)
{
htmlText = htmlText.Replace("</P><P>", Environment.NewLine);
htmlText = System.Text.RegularExpressions.Regex.Replace(htmlText, @"(?></?\w+)(?>(?:[^>'""]+|'[^']*'|""[^""]*"")*)>", String.Empty);
return htmlText;
}
public static string toFeatureStep(string inp, string prefix, string lb)
{
string[] inpAry = Regex.Split(inp, lb);
if (inpAry.Length == 1)
return inp;
StringBuilder sb = new StringBuilder(inpAry[0] + lb);
for (int i = 1; i < inpAry.Length - 1; i++)
sb.Append(prefix + inpAry[i] + lb);
sb.Append(prefix + inpAry[inpAry.Length - 1]);
return sb.ToString();
}
public static void Info(string message)
{
Trace.WriteLineIf(_logger.Level == TraceLevel.Info, message);
Console.WriteLine(message);
}
public static void Debug(string message)
{
Trace.WriteLineIf(_logger.Level == TraceLevel.Verbose, message);
Console.WriteLine(message);
}
}
}