-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSyncOperation.cs
More file actions
64 lines (54 loc) · 1.87 KB
/
SyncOperation.cs
File metadata and controls
64 lines (54 loc) · 1.87 KB
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
using System;
namespace DirectorySync
{
public enum ItemOperation {
None,
CopyToA,
CopyToB,
DeleteFromA,
DeleteFromB
}
public static class ItemOperationExtensions {
private static int maxlen = 11;
public static string ToString(this ItemOperation op, bool padded = false) {
string name = op == ItemOperation.None ? "" : Enum.GetName(typeof(ItemOperation), op);
return name + new string(' ', maxlen - name.Length);
}
}
public enum StatusOperation {
None,
AddToStatus,
UpdateStatus,
DeleteFromStatus
}
public static class StatusOperationExtensions {
private static int maxlen = 16;
public static string ToString(this StatusOperation op, bool padded = false) {
string name = op == StatusOperation.None ? "" : Enum.GetName(typeof(StatusOperation), op);
return name + new string(' ', maxlen - name.Length);
}
}
public class SyncOperation<T>
{
public SyncOperation(SyncItem<T> item) {
this.Item = item;
}
public SyncItem<T> Item { get; set; }
public string Reason { get; set; }
public ItemOperation ItemOperation { get; set; }
public StatusOperation StatusOperation { get; set; }
public string ToString(int keyLength) {
int padding;
if (keyLength == -1) padding = 2;
else padding = keyLength - Item.Key.Length;
string opLine = $"{new string(' ', 4)}{Item.Key}{new string(' ', padding)}";
opLine += ItemOperation.ToString(padded: true) + " ";
opLine += StatusOperation.ToString(padded: true) + " ";
opLine += Reason;
return opLine;
}
public override string ToString() {
return ToString(-1);
}
}
}