private bool EvaluateDisplayCondition(PSObject so, ExpressionToken conditionToken) { if (conditionToken == null) return true; PSPropertyExpression ex = _expressionFactory.CreateFromExpressionToken(conditionToken, _loadingInfo); PSPropertyExpressionResult expressionResult; bool retVal = DisplayCondition.Evaluate(so, ex, out expressionResult); if (expressionResult != null && expressionResult.Exception != null) { _errorManager.LogPSPropertyExpressionFailedResult(expressionResult, so); } return retVal; }
private void ProcessActiveAssociationList(PSObject so, TraversalInfo currentLevel, List<MshResolvedExpressionParameterAssociation> activeAssociationList, List<FormatValue> formatValueList) { foreach (MshResolvedExpressionParameterAssociation a in activeAssociationList) { FormatTextField ftf = new FormatTextField(); ftf.text = a.ResolvedExpression.ToString() + " = "; formatValueList.Add(ftf); // compute the value of the entry List<PSPropertyExpressionResult> resList = a.ResolvedExpression.GetValues(so); object val = null; if (resList.Count >= 1) { PSPropertyExpressionResult result = resList[0]; if (result.Exception != null) { _errorManager.LogPSPropertyExpressionFailedResult(result, so); if (_errorManager.DisplayErrorStrings) { val = _errorManager.ErrorString; } else { val = string.Empty; } } else { val = result.Result; } } // extract the optional max depth TraversalInfo level = currentLevel; if (a.OriginatingParameter != null) { object maxDepthKey = a.OriginatingParameter.GetEntry(FormatParameterDefinitionKeys.DepthEntryKey); if (maxDepthKey != AutomationNull.Value) { int parameterMaxDept = (int)maxDepthKey; level = new TraversalInfo(currentLevel.Level, parameterMaxDept); } } IEnumerable e = null; if (val != null || (level.Level >= level.MaxDepth)) e = PSObjectHelper.GetEnumerable(val); if (e != null) { formatValueList.Add(new FormatNewLine()); DisplayEnumeration(e, level.NextLevel, AddIndentationLevel(formatValueList)); } else if (val == null || TreatAsLeafNode(val, level)) { DisplayLeaf(val, formatValueList); } else { formatValueList.Add(new FormatNewLine()); // we need to go one more level down DisplayObject(PSObject.AsPSObject(val), level.NextLevel, null, AddIndentationLevel(formatValueList)); } } }