forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColumnInfo.cs
More file actions
59 lines (49 loc) · 1.74 KB
/
Copy pathColumnInfo.cs
File metadata and controls
59 lines (49 loc) · 1.74 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
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System;
using System.Management.Automation;
using System.Management.Automation.Internal;
namespace Microsoft.PowerShell.Commands
{
internal abstract class ColumnInfo
{
protected string displayName;
protected string staleObjectPropertyName;
internal ColumnInfo(string staleObjectPropertyName, string displayName)
{
this.displayName = displayName;
this.staleObjectPropertyName = GraphicalHostReflectionWrapper.EscapeBinding(staleObjectPropertyName);
}
internal string StaleObjectPropertyName()
{
return this.staleObjectPropertyName;
}
internal string DisplayName()
{
return this.displayName;
}
internal abstract object GetValue(PSObject liveObject);
internal Type GetValueType(PSObject liveObject, out object columnValue)
{
columnValue = GetValue(liveObject);
if (columnValue != null && columnValue is IComparable)
{
return columnValue.GetType();
}
return typeof(string); // Use the String type as default.
}
/// <summary>
/// Auxiliar used in GetValue methods since the list does not deal well with unlimited sized lines.
/// </summary>
/// <param name="src">Source string.</param>
/// <returns>The source string limited in the number of lines.</returns>
internal static object LimitString(object src)
{
if (src is not string srcString)
{
return src;
}
return HostUtilities.GetMaxLines(srcString, 10);
}
}
}