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
42 lines (35 loc) · 1.18 KB
/
Copy pathExpressionColumnInfo.cs
File metadata and controls
42 lines (35 loc) · 1.18 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
//
// Copyright (C) Microsoft. All rights reserved.
//
namespace Microsoft.PowerShell.Commands
{
using System;
using System.Collections.Generic;
using System.Management.Automation;
using Microsoft.PowerShell.Commands.Internal.Format;
internal class ExpressionColumnInfo : ColumnInfo
{
private MshExpression _expression;
internal ExpressionColumnInfo(string staleObjectPropertyName, string displayName, MshExpression expression)
: base(staleObjectPropertyName, displayName)
{
_expression = expression;
}
internal override Object GetValue(PSObject liveObject)
{
List<MshExpressionResult> resList = _expression.GetValues(liveObject);
if (resList.Count == 0)
{
return null;
}
// Only first element is used.
MshExpressionResult result = resList[0];
if (result.Exception != null)
{
return null;
}
object objectResult = result.Result;
return objectResult == null ? String.Empty : ColumnInfo.LimitString(objectResult.ToString());
}
}
}