예제 #1
0
 private void TryRemoveTaskFromExecution()
 {
     if (_currentState == TokenState.Undefined)
     {
         _remover.Remove(_task);
     }
 }
 private static void RemoveElementsFromCollection(StringBuilder builder, int numberOfRemoveOperations, IRemovable collection)
 {
     for (int i = 0; i < numberOfRemoveOperations; i++)
     {
         builder.Append(collection.Remove())
         .Append(' ');
     }
     builder.AppendLine();
 }
예제 #3
0
    private static void RemoveElementsFromCollection(StringBuilder sBuilder, IRemovable collection, int numberOfRemoves)
    {
        for (int i = 0; i < numberOfRemoves; i++)
        {
            sBuilder.Append(collection.Remove());
            sBuilder.Append(" ");
        }

        sBuilder.AppendLine();
    }
    private static void RemoveElementsFromCollection(IRemovable addRemoveCollection, int countRemoveElements)
    {
        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < countRemoveElements; i++)
        {
            sb.Append(addRemoveCollection.Remove())
            .Append(' ');
        }
        Console.WriteLine(sb.ToString().Trim());
    }
예제 #5
0
 /// <summary>Wrapper for the "Remove" method to help with exceptions.</summary>
 /// <typeparam name="T">The generic type of the structure.</typeparam>
 /// <param name="structure">The structure.</param>
 /// <param name="removal">The item to be removed.</param>
 /// <returns>True if successful, False if not.</returns>
 public static bool TryRemove <T>(this IRemovable <T> structure, T removal)
 {
     try
     {
         structure.Remove(removal);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
예제 #6
0
        /// <summary>Wrapper for the "Remove" method to help with exceptions.</summary>
        /// <typeparam name="T">The generic type of the structure.</typeparam>
        /// <param name="structure">The data structure.</param>
        /// <param name="removal">The item to be removed.</param>
        /// <returns>True if successful, False if not.</returns>
        public static bool TryRemove <T>(this IRemovable <T> structure, T removal)
        {
            // Note: This is most likely a bad practice. try-catch-ing should
            // not be used for control flow like this. I will likely be moving this
            // method into the "IRemovable<T>" interface in the future.

            try
            {
                structure.Remove(removal);
                return(true);
            }
            catch
            {
                return(false);
            }
        }
 /// <summary>
 /// Remove an item from the <see cref="IPagedDataSet"/> with the specified position
 /// </summary>
 /// <param name="dataSet">The dataset to modify</param>
 /// <param name="index">The position to remove</param>
 /// <returns></returns>
 public static async Task RemoveAt(this IRemovable removable, IPagedDataSet dataSet, int index)
 => await removable.Remove((await dataSet.GetDataSource()).ElementAtOrDefault(index));