-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDataProcessingExtensions.cs
67 lines (57 loc) · 1.87 KB
/
DataProcessingExtensions.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
61
62
63
64
65
66
67
using CommonMark;
using Microsoft.AspNetCore.Components;
namespace MessengerComparison
{
public static class DataProcessingExtensions
{
public static MarkupString ToHtml(this string s)
{
if(!s.Contains("](") && !s.Contains(" \n"))
return (MarkupString)s;
var result = CommonMarkConverter.Convert(s);
if (result.StartsWith("<p>"))
{
result = result.Remove(0, 3);
result = result.Remove(result.LastIndexOf("</p>"), 4);
}
return (MarkupString)result;
}
public static (string, MarkupString) GetScoreValue(this string s)
{
var array = s.Split('|');
if(array.Length == 2)
{
return (array[0], array[1].ToHtml());
}
else if(array.Length == 1)
{
return (string.Empty, array[0].ToHtml());
}
else
{
return (array[0], s.Remove(0, array[0].Length + 1).ToHtml());
}
}
public static bool AreTelegramFeaturesPresent(this Aspect aspect)
{
foreach(var feature in aspect.Features)
if(!string.IsNullOrEmpty(feature.Telegram))
return true;
return false;
}
public static bool AreViberFeaturesPresent(this Aspect aspect)
{
foreach(var feature in aspect.Features)
if(!string.IsNullOrEmpty(feature.Viber))
return true;
return false;
}
public static bool AreWhatsAppFeaturesPresent(this Aspect aspect)
{
foreach(var feature in aspect.Features)
if(!string.IsNullOrEmpty(feature.WhatsApp))
return true;
return false;
}
}
}