/// <summary> /// Try to match the expression against the array of wildcard patterns. /// The first match shortcircuits the search. /// </summary> /// <param name="expression">PSPropertyExpression to test against.</param> /// <returns>True if there is a match, else false.</returns> internal bool IsMatch(PSPropertyExpression expression) { for (int k = 0; k < _wildcardPatterns.Length; k++) { if (_wildcardPatterns[k].IsMatch(expression.ToString())) return true; } return false; }
/// <summary> /// To write the Property name. /// </summary> private static void WritePropertyName(StringBuilder Listtag, MshParameter p) { // for writing the property name string label = p.GetEntry(ConvertHTMLParameterDefinitionKeys.LabelEntryKey) as string; if (label != null) { Listtag.Append(label); } else { PSPropertyExpression ex = p.GetEntry(FormatParameterDefinitionKeys.ExpressionEntryKey) as PSPropertyExpression; Listtag.Append(ex.ToString()); } }
private static void EvaluateSortingExpression( MshParameter p, PSObject inputObject, List <ObjectCommandPropertyValue> orderValues, List <ErrorRecord> errors, out string propertyNotFoundMsg, ref bool comparable) { // NOTE: we assume globbing was not allowed in input PSPropertyExpression ex = p.GetEntry(FormatParameterDefinitionKeys.ExpressionEntryKey) as PSPropertyExpression; // get the values, but do not expand aliases List <PSPropertyExpressionResult> expressionResults = ex.GetValues(inputObject, false, true); if (expressionResults.Count == 0) { // we did not get any result out of the expression: // we enter a null as a place holder orderValues.Add(ObjectCommandPropertyValue.NonExistingProperty); propertyNotFoundMsg = StringUtil.Format(SortObjectStrings.PropertyNotFound, ex.ToString()); return; } propertyNotFoundMsg = null; // we obtained some results, enter them into the list foreach (PSPropertyExpressionResult r in expressionResults) { if (r.Exception == null) { orderValues.Add(new ObjectCommandPropertyValue(r.Result)); } else { ErrorRecord errorRecord = new ErrorRecord( r.Exception, "ExpressionEvaluation", ErrorCategory.InvalidResult, inputObject); errors.Add(errorRecord); orderValues.Add(ObjectCommandPropertyValue.ExistingNullProperty); } comparable = true; } }