forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExpressionColumnInfo.cs
More file actions
39 lines (32 loc) · 1.16 KB
/
Copy pathExpressionColumnInfo.cs
File metadata and controls
39 lines (32 loc) · 1.16 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
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System.Collections.Generic;
using System.Management.Automation;
namespace Microsoft.PowerShell.Commands
{
internal sealed class ExpressionColumnInfo : ColumnInfo
{
private readonly PSPropertyExpression _expression;
internal ExpressionColumnInfo(string staleObjectPropertyName, string displayName, PSPropertyExpression expression)
: base(staleObjectPropertyName, displayName)
{
_expression = expression;
}
internal override object GetValue(PSObject liveObject)
{
List<PSPropertyExpressionResult> resList = _expression.GetValues(liveObject);
if (resList.Count == 0)
{
return null;
}
// Only first element is used.
PSPropertyExpressionResult result = resList[0];
if (result.Exception != null)
{
return null;
}
object objectResult = result.Result;
return objectResult == null ? string.Empty : ColumnInfo.LimitString(objectResult.ToString());
}
}
}