예제 #1
0
        /// <summary>
        /// Gets a task from the tasks list by name
        /// </summary>
        /// <param name="tasksList"></param>
        /// <param name="taskName"></param>
        /// <returns></returns>
        public static ISNTaskObj GetByName(this ISNTasksList tasksList, string taskName)
        {
            tasksList.Reset();

            while (!tasksList.EndOfList)
            {
                var task = tasksList.Current;

                if (task.Name.Equals(taskName, StringComparison.InvariantCultureIgnoreCase))
                {
                    return(task);
                }

                tasksList.MoveNext();
            }
            return(null);
        }
예제 #2
0
        /// <summary>
        /// Removes a task from the tasks list by name
        /// </summary>
        /// <param name="tasksList"></param>
        /// <param name="taskName"></param>
        /// <returns></returns>
        public static bool RemoveByName(this ISNTasksList tasksList, string taskName)
        {
            tasksList.Reset();

            while (!tasksList.EndOfList)
            {
                var task = tasksList.Current;

                if (task.Name.Equals(taskName, StringComparison.InvariantCultureIgnoreCase))
                {
                    tasksList.Remove();
                    return(true);
                }

                tasksList.MoveNext();
            }
            return(false);
        }