Esempio n. 1
0
 /// <summary>
 /// will add to collection, ignoring if already exists
 /// (making all adds idempotent)
 /// </summary>
 /// <param name="col"></param>
 /// <param name="status"></param>
 public static void AddWithMerge(this ICollection<Status> col, Status status)
 {
     if (!col.ContainsStatus(status))
     {
         col.Add(status);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// will match ONLY a status with matching StatusValue,
        /// AND matching StampedAt fields.
        /// </summary>
        /// <param name="ie"></param>
        /// <param name="statusValue"></param>
        /// <returns></returns>
        public static bool ContainsStatus(this IEnumerable<Status> ie, Status status)
        {
            bool found = false;

            foreach (Status s in ie)
            {
                if (found == false &&
                    s.StatusValue.Equals(status.StatusValue,
                        StringComparison.CurrentCultureIgnoreCase) &&
                    s.StampedAt.Equals(status.StampedAt))
                {
                    found = true;
                }
            }

            return found;
        }