Thinktecture.Tools.Web.Services.ContractFirst.VisualStudio.AddTask C# (CSharp) Method

AddTask() public method

public AddTask ( string description, string category, string subcategory, vsTaskPriority priority, vsTaskIcon icon, bool checkable, string releventFile, int lineNumber, bool canUserDelete, bool flushItem, bool allowDuplicates ) : void
description string
category string
subcategory string
priority vsTaskPriority
icon vsTaskIcon
checkable bool
releventFile string
lineNumber int
canUserDelete bool
flushItem bool
allowDuplicates bool
return void
        public void AddTask(string description,
            string category,
            string subcategory,
            vsTaskPriority priority,
            vsTaskIcon icon,
            bool checkable,
            string releventFile,
            int lineNumber,
            bool canUserDelete,
            bool flushItem,
            bool allowDuplicates)
        {
            Debug.Assert(description != null, "description parameter could not be null.");
            Debug.Assert(category != null, "category parameter could not be null.");
            Debug.Assert(subcategory != null, "subcategory parameter could not be null.");

            // Get a reference to the tasks window.
            Window win = applicationObject.Windows.Item(Constants.vsWindowKindTaskList);
            // Activate it.
            win.Activate();
            // Get a reference to the tasks list.
            TaskList taskList = (TaskList)win.Object;

            // If we don't allow duplicates we have to itterate the tasks list to
            // see if there is a duplicate.

            // Do this for all task items.
            for (int ti = 1; ti <= taskList.TaskItems.Count; ti++)
            {
                // Get a reference to the task item.
                TaskItem existingItem = taskList.TaskItems.Item(ti);
                // Match attributes and see if this task is as same as the one being added.
                // If the task is matching all Category, SubCategory and Description properties
                // must be similar to the pertaining parameters. We don't care about the case here.
                if (string.Compare(category, existingItem.Category, true) == 0 &&
                    string.Compare(subcategory, existingItem.SubCategory, true) == 0 &&
                    string.Compare(description, existingItem.Description, true) == 0)
                {
                    // We don't have to proceed.
                    return;
                }
            }

            // Add the new task item.
            TaskItem newItem = taskList.TaskItems.Add(category, subcategory, description, priority, icon,
                checkable, releventFile, lineNumber, canUserDelete, flushItem);

            // Finally activate the task bar.
            ActivateTaskBar();
        }