コード例 #1
0
        /// <summary>
        /// Retrieve many values from an array of bindings.
        /// </summary>
        /// <param name="cmdlet">The cmdlet to operate on.</param>
        /// <param name="bindings">The bindings to use.</param>
        /// <param name="values">The value to output.</param>
        /// <param name="queryType">The type of query.</param>
        /// <param name="queryValue">The value of the query.</param>
        /// <typeparam name="R">The type of object to retrieve</typeparam>
        /// <returns>True if all valid values were retrieved; false if any binding was not resolved.</returns>
        internal static bool GetManyValues <R>(this Cmdlet cmdlet, ObjectBinding <R>[] bindings, out ResponseCollection <R> values,
                                               string queryType = "identity", string queryValue = null)
            where R : AbstractBaseModel, new()
        {
            var result = true;

            values = new ResponseCollection <R>();
            foreach (var binding in bindings)
            {
                result = cmdlet.GetSingleValue(binding, out var value, queryType, queryValue) && result;
                if (result)
                {
                    values.Add(value);
                }
            }
            if (!result)
            {
                values = null;
            }
            return(result);
        }