Beispiel #1
0
        /// <summary>
        /// Utility function used to create OrderByPropertyEntry for the supplied input object.
        /// </summary>
        /// <param name="cmdlet">PSCmdlet.</param>
        /// <param name="inputObject">Input Object.</param>
        /// <param name="isCaseSensitive">Indicates if the Property value comparisons need to be case sensitive or not.</param>
        /// <param name="cultureInfo">Culture Info that needs to be used for comparison.</param>
        /// <returns>OrderByPropertyEntry for the supplied InputObject.</returns>
        internal OrderByPropertyEntry CreateOrderByPropertyEntry(
            PSCmdlet cmdlet,
            PSObject inputObject,
            bool isCaseSensitive,
            CultureInfo cultureInfo)
        {
            Diagnostics.Assert(cmdlet != null, "cmdlet must be an instance");

            if (_unExpandedParametersWithWildCardPattern != null)
            {
                ExpandExpressions(inputObject, _unExpandedParametersWithWildCardPattern, _mshParameterList);
            }

            List <ErrorRecord>   evaluationErrors     = new();
            List <string>        propertyNotFoundMsgs = new();
            OrderByPropertyEntry result =
                OrderByPropertyEntryEvaluationHelper.ProcessObject(inputObject, _mshParameterList, evaluationErrors, propertyNotFoundMsgs, isCaseSensitive, cultureInfo);

            foreach (ErrorRecord err in evaluationErrors)
            {
                cmdlet.WriteError(err);
            }

            foreach (string debugMsg in propertyNotFoundMsgs)
            {
                cmdlet.WriteDebug(debugMsg);
            }

            return(result);
        }
Beispiel #2
0
        internal static List <OrderByPropertyEntry> CreateOrderMatrix(
            PSCmdlet cmdlet,
            List <PSObject> inputObjects,
            List <MshParameter> mshParameterList
            )
        {
            List <OrderByPropertyEntry> orderMatrixToCreate = new();

            for (int index = 0; index < inputObjects.Count; index++)
            {
                PSObject so = inputObjects[index];
                if (so == null || so == AutomationNull.Value)
                {
                    continue;
                }
                List <ErrorRecord>   evaluationErrors     = new();
                List <string>        propertyNotFoundMsgs = new();
                OrderByPropertyEntry result =
                    OrderByPropertyEntryEvaluationHelper.ProcessObject(so, mshParameterList, evaluationErrors, propertyNotFoundMsgs, originalIndex: index);
                foreach (ErrorRecord err in evaluationErrors)
                {
                    cmdlet.WriteError(err);
                }

                foreach (string debugMsg in propertyNotFoundMsgs)
                {
                    cmdlet.WriteDebug(debugMsg);
                }

                orderMatrixToCreate.Add(result);
            }

            return(orderMatrixToCreate);
        }