Exemple #1
0
 /// <summary>
 /// Add if item is not null or empty
 /// </summary>
 /// <typeparam name="TItem"></typeparam>
 /// <param name="list"></param>
 /// <param name="item"></param>
 public static void AddIfNotNullOrEmpty <TItem>(this IList <TItem> list, Func <TItem> item)
 {
     CheckValue.NotNullOrEmpty(() => list.Add(item()), item);
 }
Exemple #2
0
 /// <summary>
 /// <para>Add item to list if value of T checkNotNullOrEmpty is not null or empty. </para>
 /// <para>If item creation is declared on Add it will never be Created and Initialized if checkValueNotNullOrEmpty is null or empty.</para>
 /// <para>&#160;</para>
 /// <para>Usage:</para>
 /// <para>list.Add(() => new TItem(args), checkNotNullOrEmpty);</para>
 /// <para>&#160;</para>
 /// <para>Example:</para>
 /// <para>list.Add(() => new Product(product.Id, product.Name, product.Category), product.Name);</para>
 /// </summary>
 /// <typeparam name="TItem"></typeparam>
 /// <typeparam name="TValue"></typeparam>
 /// <param name="list"></param>
 /// <param name="item"></param>
 /// <param name="checkNotNullOrEmpty"></param>
 public static void Add <TItem, TValue>(this IList <TItem> list, Func <TItem> item, TValue checkNotNullOrEmpty)
 {
     CheckValue.NotNullOrEmpty(() => list.Add(item()), checkNotNullOrEmpty);
 }