Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public sealed class ConvertFromStringDataCommand : PSCmdlet

/// <summary>
/// The list of properties to display
/// These take the form of an MshExpression
/// These take the form of an PSPropertyExpression
/// </summary>
/// <value></value>
[Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@ namespace Microsoft.PowerShell.Commands

internal class ExpressionColumnInfo : ColumnInfo
{
private MshExpression _expression;
private PSPropertyExpression _expression;

internal ExpressionColumnInfo(string staleObjectPropertyName, string displayName, MshExpression expression)
internal ExpressionColumnInfo(string staleObjectPropertyName, string displayName, PSPropertyExpression expression)
: base(staleObjectPropertyName, displayName)
{
_expression = expression;
}

internal override Object GetValue(PSObject liveObject)
{
List<MshExpressionResult> resList = _expression.GetValues(liveObject);
List<PSPropertyExpressionResult> resList = _expression.GetValues(liveObject);

if (resList.Count == 0)
{
return null;
}

// Only first element is used.
MshExpressionResult result = resList[0];
PSPropertyExpressionResult result = resList[0];
if (result.Exception != null)
{
return null;
Expand All @@ -38,4 +38,4 @@ internal override Object GetValue(PSObject liveObject)
return objectResult == null ? String.Empty : ColumnInfo.LimitString(objectResult.ToString());
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class OutGridViewCommand : PSCmdlet, IDisposable
private const string DataNotQualifiedForGridView = "DataNotQualifiedForGridView";
private const string RemotingNotSupported = "RemotingNotSupported";
private TypeInfoDataBase _typeInfoDataBase;
private MshExpressionFactory _expressionFactory;
private PSPropertyExpressionFactory _expressionFactory;
private OutWindowProxy _windowProxy;
private GridHeader _gridHeader;

Expand Down Expand Up @@ -110,7 +110,7 @@ public SwitchParameter PassThru
protected override void BeginProcessing()
{
// Set up the ExpressionFactory
_expressionFactory = new MshExpressionFactory();
_expressionFactory = new PSPropertyExpressionFactory();

// If the value of the Title parameter is valid, use it as a window's title.
if (this.Title != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ namespace Microsoft.PowerShell.Commands

internal class TableView
{
private MshExpressionFactory _expressionFactory;
private PSPropertyExpressionFactory _expressionFactory;
private TypeInfoDataBase _typeInfoDatabase;
private FormatErrorManager _errorManager;

internal void Initialize(MshExpressionFactory expressionFactory,
internal void Initialize(PSPropertyExpressionFactory expressionFactory,
TypeInfoDataBase db)
{
_expressionFactory = expressionFactory;
Expand Down Expand Up @@ -78,7 +78,7 @@ internal HeaderInfo GenerateHeaderInfo(PSObject input, TableControlBody tableBod
}
if (fpt.expression.isScriptBlock)
{
MshExpression ex = _expressionFactory.CreateFromExpressionToken(fpt.expression);
PSPropertyExpression ex = _expressionFactory.CreateFromExpressionToken(fpt.expression);
// Using the displayName as a propertyName for a stale PSObject.
const string LastWriteTimePropertyName = "LastWriteTime";

Expand Down Expand Up @@ -132,7 +132,7 @@ internal HeaderInfo GenerateHeaderInfo(PSObject input, OutGridViewCommand parent
if (PSObjectHelper.ShouldShowComputerNameProperty(input))
{
activeAssociationList.Add(new MshResolvedExpressionParameterAssociation(null,
new MshExpression(RemotingConstants.ComputerNameNoteProperty)));
new PSPropertyExpression(RemotingConstants.ComputerNameNoteProperty)));
}
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ public GenericMeasureInfo()
/// Class output by Measure-Object.
/// </summary>
/// <remarks>
/// This class is created for fixing "Measure-Object -MAX -MIN should work with ANYTHING that supports CompareTo"
/// bug (Win8:343911).
/// This class is created to make 'Measure-Object -MAX -MIN' work with ANYTHING that supports 'CompareTo'.
/// GenericMeasureInfo class is shipped with PowerShell V2. Fixing this bug requires, changing the type of
/// Maximum and Minimum properties which would be a breaking change. Hence created a new class to not
/// have an appcompat issues with PS V2.
Expand Down Expand Up @@ -271,7 +270,7 @@ public MeasureObjectCommand()
/// <value></value>
[ValidateNotNullOrEmpty]
[Parameter(Position = 0)]
public string[] Property { get; set; } = null;
public PSPropertyExpression[] Property { get; set; } = null;

#endregion Common parameters in both sets

Expand Down Expand Up @@ -486,10 +485,9 @@ private void AnalyzeObjectProperties(PSObject inObj)

// First iterate over the user-specified list of
// properties...
foreach (string p in Property)
foreach (var expression in Property)
{
MshExpression expression = new MshExpression(p);
List<MshExpression> resolvedNames = expression.ResolveNames(inObj);
List<PSPropertyExpression> resolvedNames = expression.ResolveNames(inObj);
if (resolvedNames == null || resolvedNames.Count == 0)
{
// Insert a blank entry so we can track
Expand All @@ -506,7 +504,7 @@ private void AnalyzeObjectProperties(PSObject inObj)
// Each property value can potentially refer
// to multiple properties via globbing. Iterate over
// the actual property names.
foreach (MshExpression resolvedName in resolvedNames)
foreach (PSPropertyExpression resolvedName in resolvedNames)
{
string propertyName = resolvedName.ToString();
// skip duplicated properties
Expand All @@ -515,7 +513,7 @@ private void AnalyzeObjectProperties(PSObject inObj)
continue;
}

List<MshExpressionResult> tempExprRes = resolvedName.GetValues(inObj);
List<PSPropertyExpressionResult> tempExprRes = resolvedName.GetValues(inObj);
if (tempExprRes == null || tempExprRes.Count == 0)
{
// Shouldn't happen - would somehow mean
Expand Down Expand Up @@ -573,7 +571,7 @@ private void AnalyzeValue(string propertyName, object objValue)
AnalyzeNumber(numValue, stat);
}

// Win8:343911 Measure-Object -MAX -MIN should work with ANYTHING that supports CompareTo
// Measure-Object -MAX -MIN should work with ANYTHING that supports CompareTo
if (_measureMin)
{
stat.min = Compare(objValue, stat.min, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ internal List<MshParameter> MshParameterList
// a string array and allows wildcard.
// Yes, the Cmdlet is needed. It's used to get the TerminatingErrorContext, WriteError and WriteDebug.

#region process MshExpression and MshParameter
#region process PSPropertyExpression and MshParameter

private static void ProcessExpressionParameter(
List<PSObject> inputObjects,
Expand Down Expand Up @@ -245,7 +245,7 @@ internal void ProcessExpressionParameter(

foreach (MshParameter unexpandedParameter in _unexpandedParameterList)
{
MshExpression mshExpression = (MshExpression)unexpandedParameter.GetEntry(FormatParameterDefinitionKeys.ExpressionEntryKey);
PSPropertyExpression mshExpression = (PSPropertyExpression)unexpandedParameter.GetEntry(FormatParameterDefinitionKeys.ExpressionEntryKey);
if (!mshExpression.HasWildCardCharacters) // this special cases 1) script blocks and 2) wildcard-less strings
{
_mshParameterList.Add(unexpandedParameter);
Expand Down Expand Up @@ -274,14 +274,14 @@ private static List<MshParameter> ExpandExpressions(List<PSObject> inputObjects,
{
foreach (MshParameter unexpandedParameter in unexpandedParameterList)
{
MshExpression ex = (MshExpression)unexpandedParameter.GetEntry(FormatParameterDefinitionKeys.ExpressionEntryKey);
PSPropertyExpression ex = (PSPropertyExpression)unexpandedParameter.GetEntry(FormatParameterDefinitionKeys.ExpressionEntryKey);
if (!ex.HasWildCardCharacters) // this special cases 1) script blocks and 2) wildcard-less strings
{
expandedParameterList.Add(unexpandedParameter);
}
else
{
SortedDictionary<string, MshExpression> expandedPropertyNames = new SortedDictionary<string, MshExpression>(StringComparer.OrdinalIgnoreCase);
SortedDictionary<string, PSPropertyExpression> expandedPropertyNames = new SortedDictionary<string, PSPropertyExpression>(StringComparer.OrdinalIgnoreCase);
if (inputObjects != null)
{
foreach (object inputObject in inputObjects)
Expand All @@ -291,14 +291,14 @@ private static List<MshParameter> ExpandExpressions(List<PSObject> inputObjects,
continue;
}

foreach (MshExpression resolvedName in ex.ResolveNames(PSObject.AsPSObject(inputObject)))
foreach (PSPropertyExpression resolvedName in ex.ResolveNames(PSObject.AsPSObject(inputObject)))
{
expandedPropertyNames[resolvedName.ToString()] = resolvedName;
}
}
}

foreach (MshExpression expandedExpression in expandedPropertyNames.Values)
foreach (PSPropertyExpression expandedExpression in expandedPropertyNames.Values)
{
MshParameter expandedParameter = new MshParameter();
expandedParameter.hash = (Hashtable)unexpandedParameter.hash.Clone();
Expand All @@ -321,20 +321,20 @@ private static void ExpandExpressions(PSObject inputObject, List<MshParameter> U
{
foreach (MshParameter unexpandedParameter in UnexpandedParametersWithWildCardPattern)
{
MshExpression ex = (MshExpression)unexpandedParameter.GetEntry(FormatParameterDefinitionKeys.ExpressionEntryKey);
PSPropertyExpression ex = (PSPropertyExpression)unexpandedParameter.GetEntry(FormatParameterDefinitionKeys.ExpressionEntryKey);

SortedDictionary<string, MshExpression> expandedPropertyNames = new SortedDictionary<string, MshExpression>(StringComparer.OrdinalIgnoreCase);
SortedDictionary<string, PSPropertyExpression> expandedPropertyNames = new SortedDictionary<string, PSPropertyExpression>(StringComparer.OrdinalIgnoreCase);
if (inputObject == null)
{
continue;
}

foreach (MshExpression resolvedName in ex.ResolveNames(PSObject.AsPSObject(inputObject)))
foreach (PSPropertyExpression resolvedName in ex.ResolveNames(PSObject.AsPSObject(inputObject)))
{
expandedPropertyNames[resolvedName.ToString()] = resolvedName;
}

foreach (MshExpression expandedExpression in expandedPropertyNames.Values)
foreach (PSPropertyExpression expandedExpression in expandedPropertyNames.Values)
{
MshParameter expandedParameter = new MshParameter();
expandedParameter.hash = (Hashtable)unexpandedParameter.hash.Clone();
Expand Down Expand Up @@ -364,7 +364,7 @@ internal static string[] GetDefaultKeyPropertySet(PSObject mshObj)
return props;
}

#endregion process MshExpression and MshParameter
#endregion process PSPropertyExpression and MshParameter

internal static List<OrderByPropertyEntry> CreateOrderMatrix(
PSCmdlet cmdlet,
Expand Down Expand Up @@ -569,10 +569,10 @@ private static void EvaluateSortingExpression(
ref bool comparable)
{
// NOTE: we assume globbing was not allowed in input
MshExpression ex = p.GetEntry(FormatParameterDefinitionKeys.ExpressionEntryKey) as MshExpression;
PSPropertyExpression ex = p.GetEntry(FormatParameterDefinitionKeys.ExpressionEntryKey) as PSPropertyExpression;

// get the values, but do not expand aliases
List<MshExpressionResult> expressionResults = ex.GetValues(inputObject, false, true);
List<PSPropertyExpressionResult> expressionResults = ex.GetValues(inputObject, false, true);

if (expressionResults.Count == 0)
{
Expand All @@ -584,7 +584,7 @@ private static void EvaluateSortingExpression(
}
propertyNotFoundMsg = null;
// we obtained some results, enter them into the list
foreach (MshExpressionResult r in expressionResults)
foreach (PSPropertyExpressionResult r in expressionResults)
{
if (r.Exception == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public PSObject InputObject

/// <summary>
/// The list of properties to display
/// These take the form of an MshExpression
/// These take the form of a PSPropertyExpression
/// </summary>
/// <value></value>
[Parameter(Position = 0)]
Expand Down Expand Up @@ -342,9 +342,9 @@ private void InitializeResolvedNameMshParameters()
string label = p.GetEntry(ConvertHTMLParameterDefinitionKeys.LabelEntryKey) as string;
string alignment = p.GetEntry(ConvertHTMLParameterDefinitionKeys.AlignmentEntryKey) as string;
string width = p.GetEntry(ConvertHTMLParameterDefinitionKeys.WidthEntryKey) as string;
MshExpression ex = p.GetEntry(FormatParameterDefinitionKeys.ExpressionEntryKey) as MshExpression;
List<MshExpression> resolvedNames = ex.ResolveNames(_inputObject);
foreach (MshExpression resolvedName in resolvedNames)
PSPropertyExpression ex = p.GetEntry(FormatParameterDefinitionKeys.ExpressionEntryKey) as PSPropertyExpression;
List<PSPropertyExpression> resolvedNames = ex.ResolveNames(_inputObject);
foreach (PSPropertyExpression resolvedName in resolvedNames)
{
Hashtable ht = CreateAuxPropertyHT(label, alignment, width);
ht.Add(FormatParameterDefinitionKeys.ExpressionEntryKey, resolvedName.ToString());
Expand Down Expand Up @@ -567,7 +567,7 @@ private void WritePropertyName(StringBuilder Listtag, MshParameter p)
}
else
{
MshExpression ex = p.GetEntry(FormatParameterDefinitionKeys.ExpressionEntryKey) as MshExpression;
PSPropertyExpression ex = p.GetEntry(FormatParameterDefinitionKeys.ExpressionEntryKey) as PSPropertyExpression;
Listtag.Append(ex.ToString());
}
}
Expand All @@ -577,11 +577,11 @@ private void WritePropertyName(StringBuilder Listtag, MshParameter p)
/// </summary>
private void WritePropertyValue(StringBuilder Listtag, MshParameter p)
{
MshExpression exValue = p.GetEntry(FormatParameterDefinitionKeys.ExpressionEntryKey) as MshExpression;
PSPropertyExpression exValue = p.GetEntry(FormatParameterDefinitionKeys.ExpressionEntryKey) as PSPropertyExpression;

// get the value of the property
List<MshExpressionResult> resultList = exValue.GetValues(_inputObject);
foreach (MshExpressionResult result in resultList)
List<PSPropertyExpressionResult> resultList = exValue.GetValues(_inputObject);
foreach (PSPropertyExpressionResult result in resultList)
{
// create comma sep list for multiple results
if (result.Result != null)
Expand Down
Loading