Repository navigation
Expand file tree
/
Copy pathColumnTransformation.cs
More file actions
137 lines (120 loc) · 4.59 KB
/
Copy pathColumnTransformation.cs
File metadata and controls
137 lines (120 loc) · 4.59 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
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
using System;
using System.Collections;
using System.Management.Automation;
namespace PSModuleDevelopment.Format
{
/// <summary>
/// A set of transformation rules that determine, wheter a column needs to be updated
/// </summary>
public class ColumnTransformation
{
/// <summary>
/// A filter rule, based on the name of the view
/// </summary>
public string FilterViewName = "*";
/// <summary>
/// A filter rule, based on the name of the column
/// </summary>
public string FilterColumnName;
/// <summary>
/// Whether the rule should be added as an additional property, if no matching ColumName was found.
/// </summary>
public bool Append;
/// <summary>
/// A scriptblock to determine column content at runtime
/// </summary>
public ScriptBlock ScriptBlock;
/// <summary>
/// The label to apply to the column
/// </summary>
public string Label;
/// <summary>
/// Total width of the column. Anything less than one will be ignored.
/// </summary>
public int Width;
/// <summary>
/// How to align the text.
/// </summary>
public Alignment Alignment = Alignment.Undefined;
/// <summary>
/// Empty constructor for manual assembly
/// </summary>
public ColumnTransformation()
{
}
/// <summary>
/// Hashtable constructor, in order to automatically convert&understand input
/// </summary>
/// <param name="Table">The hashtable to parse</param>
public ColumnTransformation(Hashtable Table)
{
// FilterViewName
if (Table.ContainsKey("T"))
FilterViewName = (string)Table["T"];
if (Table.ContainsKey("Type"))
FilterViewName = (string)Table["Type"];
if (Table.ContainsKey("TypeName"))
FilterViewName = (string)Table["TypeName"];
if (Table.ContainsKey("FilterViewName"))
FilterViewName = (string)Table["FilterViewName"];
// FilterColumnName
if (Table.ContainsKey("C"))
FilterColumnName = (string)Table["C"];
if (Table.ContainsKey("Column"))
FilterColumnName = (string)Table["Column"];
if (Table.ContainsKey("Name"))
FilterColumnName = (string)Table["Name"];
if (Table.ContainsKey("P"))
FilterColumnName = (string)Table["P"];
if (Table.ContainsKey("Property"))
FilterColumnName = (string)Table["Property"];
if (Table.ContainsKey("PropertyName"))
FilterColumnName = (string)Table["PropertyName"];
// Append
if (Table.ContainsKey("A"))
Append = (bool)Table["A"];
if (Table.ContainsKey("Append"))
Append = (bool)Table["Append"];
// ScriptBlock
if (Table.ContainsKey("S"))
ScriptBlock = (ScriptBlock)Table["S"];
if (Table.ContainsKey("Script"))
ScriptBlock = (ScriptBlock)Table["Script"];
if (Table.ContainsKey("ScriptBlock"))
ScriptBlock = (ScriptBlock)Table["ScriptBlock"];
// Label
if (Table.ContainsKey("L"))
Label = (string)Table["L"];
if (Table.ContainsKey("Label"))
Label = (string)Table["Label"];
// Width
if (Table.ContainsKey("W"))
Width = (int)Table["W"];
if (Table.ContainsKey("Width"))
Width = (int)Table["Width"];
// Alignment
string align = "";
if (Table.ContainsKey("Align"))
align = (string)Table["Align"];
if (Table.ContainsKey("Alignment"))
align = (string)Table["Alignment"];
if (!String.IsNullOrEmpty(align))
Alignment = (Alignment)Enum.Parse(typeof(Alignment), align, false);
}
/// <summary>
/// Applies changes to column
/// </summary>
/// <param name="Item">The column to affect</param>
public void Apply(Column Item)
{
if (ScriptBlock != null)
Item.ScriptBlock = ScriptBlock;
if (!String.IsNullOrEmpty(Label))
Item.Label = Label;
if (Width > 0)
Item.Width = Width;
if (Alignment != Alignment.Undefined)
Item.Alignment = Alignment;
}
}
}