Esempio n. 1
0
        internal static MshExpression GetDisplayNameExpression(
            PSObject target,
            MshExpressionFactory expressionFactory)
        {
            MshExpression defaultNameExpression = PSObjectHelper.GetDefaultNameExpression(target);

            if (defaultNameExpression != null)
            {
                return(defaultNameExpression);
            }
            string[] strArray = new string[6]
            {
                "name",
                "id",
                "key",
                "*key",
                "*name",
                "*id"
            };
            foreach (string s in strArray)
            {
                List <MshExpression> mshExpressionList = new MshExpression(s).ResolveNames(target);
                while (mshExpressionList.Count > 0 && (mshExpressionList[0].ToString().Equals(RemotingConstants.ComputerNameNoteProperty, StringComparison.OrdinalIgnoreCase) || mshExpressionList[0].ToString().Equals(RemotingConstants.ShowComputerNameNoteProperty, StringComparison.OrdinalIgnoreCase) || mshExpressionList[0].ToString().Equals(RemotingConstants.RunspaceIdNoteProperty, StringComparison.OrdinalIgnoreCase)))
                {
                    mshExpressionList.RemoveAt(0);
                }
                if (mshExpressionList.Count != 0)
                {
                    return(mshExpressionList[0]);
                }
            }
            return((MshExpression)null);
        }
Esempio n. 2
0
 private static MshExpression GetDefaultNameExpression(PSObject so) => PSObjectHelper.GetDefaultNameExpression(so.PSStandardMembers) ?? PSObjectHelper.GetDefaultNameExpression(PSObjectHelper.MaskDeserializedAndGetStandardMembers(so));