-
Notifications
You must be signed in to change notification settings - Fork 137
/
StringBuilderExtensions.cs
97 lines (81 loc) · 2.77 KB
/
StringBuilderExtensions.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
using System;
using System.Text;
using SwqlStudio.Metadata;
namespace SwqlStudio
{
internal static class StringBuilderExtensions
{
public static void AppendName(this StringBuilder builder, string name)
{
if (builder == null)
{
throw new ArgumentNullException(nameof(builder));
}
builder.AppendFormat("Name: {0}{1}", name, Environment.NewLine);
}
public static void AppendType(this StringBuilder builder, string metadataType)
{
if (builder == null)
{
throw new ArgumentNullException(nameof(builder));
}
builder.AppendFormat("Type: {0}{1}", metadataType, Environment.NewLine);
}
public static void AppendSummaryParagraph(this StringBuilder builder, string summary)
{
if (builder == null)
{
throw new ArgumentNullException(nameof(builder));
}
builder.AppendLine();
builder.AppendLine();
builder.AppendSummary(summary);
}
public static void AppendSummary(this StringBuilder builder, string summary)
{
if (builder == null)
{
throw new ArgumentNullException(nameof(builder));
}
if (string.IsNullOrEmpty(summary))
{
return;
}
string trimmed = summary.Trim();
builder.Append(trimmed);
}
public static void AppendAccessControl(this StringBuilder builder, ConnectionInfo connection, Entity entity)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
if (connection == null)
{
throw new ArgumentNullException(nameof(connection));
}
if (entity.IsIndication)
{
builder.Append($@"Can Subscribe: {connection.CanCreateSubscription}");
}
else
{
builder.AppendLine($"Can Read: {entity.CanRead}");
builder.AppendLine($"Can Create: {entity.CanCreate}");
builder.AppendLine($"Can Update: {entity.CanUpdate}");
builder.AppendLine($"Can Delete: {entity.CanDelete}");
}
}
public static void AppendObsoleteSection(this StringBuilder builder, IObsoleteMetadata entity)
{
if (builder == null)
{
throw new ArgumentNullException(nameof(builder));
}
if (entity != null && entity.IsObsolete)
{
builder.AppendLine($"Obsolete: {entity.ObsolescenceReason}");
}
}
}
}