Exemple #1
0
        public static int Count(string listName)
        {
            #region Preconditions
            if (String.IsNullOrEmpty(listName))
            {
                throw new ArgumentException("listName cannot be null or empty");
            }
            #endregion

            return(ListManager.GetList(listName).Count);
        }
        /// <summary>
        /// Execute the task.
        /// </summary>
        protected override void ExecuteTask()
        {
            IList <string> list = ListManager.GetList(ListName);

            foreach (string val in list)
            {
                if (ValueProperty != null)
                {
                    NAntUtility.AddOrOverwriteProperty(Project, ValueProperty, val);
                }

                // Base execute handles executing all child tasks.
                base.ExecuteTask();
            }
        }
Exemple #3
0
        public static bool Contains(string listName, string val)
        {
            #region Preconditions
            if (String.IsNullOrEmpty(listName))
            {
                throw new ArgumentException("listName cannot be null or empty");
            }
            if (String.IsNullOrEmpty(val))
            {
                throw new ArgumentException("val cannot be null or empty");
            }
            #endregion

            return(ListManager.GetList(listName).Contains(val));
        }
Exemple #4
0
        public static bool IsEmpty(string listName)
        {
            #region Preconditions
            if (String.IsNullOrEmpty(listName))
            {
                throw new ArgumentException("listName cannot be null or empty");
            }
            #endregion

            if (!ListManager.ListExists(listName))
            {
                return(true);
            }
            return(ListManager.GetList(listName).Count == 0);
        }
Exemple #5
0
        /// <summary>
        /// Execute the task.
        /// </summary>
        protected override void ExecuteTask()
        {
            base.ExecuteTask();

            if (ListManager.ListExists(NewListName))
            {
                throw new BuildException(string.Format("List with name [{0}] already exists.", NewListName));
            }

            IList <string> newList = ListManager.GetList(NewListName);

            foreach (string val in List)
            {
                newList.Add(val);
            }
        }
Exemple #6
0
        public static string GetValue(string listName, int position)
        {
            #region Preconditions
            if (String.IsNullOrEmpty(listName))
            {
                throw new ArgumentException("listName cannot be null or empty");
            }
            #endregion

            IList <string> list = ListManager.GetList(listName);
            if (position < 0 || position >= list.Count)
            {
                throw new BuildException(string.Format("List [{0}] does not have a position [{1}]", list, position));
            }
            return((string)list[position]);
        }
Exemple #7
0
        public static string Shift(string listName)
        {
            #region Preconditions
            if (String.IsNullOrEmpty(listName))
            {
                throw new ArgumentException("listName cannot be null or empty");
            }
            #endregion

            IList <string> list = ListManager.GetList(listName);
            if (ListFunctions.IsEmpty(listName))
            {
                throw new BuildException(string.Format("List [{0}] is empty", listName));
            }
            string itemVal = list[0];
            list.RemoveAt(0);
            return(itemVal);
        }
Exemple #8
0
 /// <summary>
 /// Execute the task.
 /// </summary>
 protected override void ExecuteTask()
 {
     _list = ListManager.GetList(ListName);
 }