コード例 #1
0
        /// <summary>
        /// Lists the subtasks matching the specified filter options.
        /// </summary>
        /// <param name="options">The options to use when querying for subtasks.</param>
        /// <returns>The subtasks matching the specified filter options.</returns>
        public IEnumerable <PSSubtaskInformation> ListSubtasks(ListSubtaskOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            string taskId           = options.Task == null ? options.TaskId : options.Task.Id;
            string verboseLogString = string.Format(Resources.GetSubtaskNoFilter, taskId);

            WriteVerbose(verboseLogString);

            IPagedEnumerable <SubtaskInformation> subtasks = null;

            if (options.Task != null)
            {
                subtasks = options.Task.omObject.ListSubtasks(additionalBehaviors: options.AdditionalBehaviors);
            }
            else
            {
                JobOperations jobOperations = options.Context.BatchOMClient.JobOperations;
                subtasks = jobOperations.ListSubtasks(options.JobId, options.TaskId, additionalBehaviors: options.AdditionalBehaviors);
            }
            Func <SubtaskInformation, PSSubtaskInformation> mappingFunction = s => { return(new PSSubtaskInformation(s)); };

            return(PSPagedEnumerable <PSSubtaskInformation, SubtaskInformation> .CreateWithMaxCount(
                       subtasks, mappingFunction, options.MaxCount, () => WriteVerbose(string.Format(Resources.MaxCount, options.MaxCount))));
        }