Exemplo n.º 1
0
 /// <summary>
 /// When overridden in a derived class, processes a PropertyChanged event on a source item.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <param name="propertyName">Name of the property.</param>
 protected override void ReactToItemPropertyChanged(TSource item, string propertyName)
 {
     if (SourceCollection.Contains(item).Current)
     {
         EnsureGroupsExists(item);
     }
 }
Exemplo n.º 2
0
 private void okButton_Click(object sender, RoutedEventArgs e)
 {
     for (int i = SourceCollection.Count - 1; i >= 0; i--)
     {
         object o = SourceCollection[i];
         if (!SourceCollectionEdited.Contains(o))
         {
             SourceCollection.RemoveAt(i);
         }
     }
     foreach (object o in SourceCollectionEdited)
     {
         if (!SourceCollection.Contains(o))
         {
             SourceCollection.Add(o);
         }
     }
     for (int i = TargetCollection.Count - 1; i >= 0; i--)
     {
         object o = TargetCollection[i];
         if (!TargetCollectionEdited.Contains(o))
         {
             TargetCollection.RemoveAt(i);
         }
     }
     foreach (object o in TargetCollectionEdited)
     {
         if (!TargetCollection.Contains(o))
         {
             TargetCollection.Add(o);
         }
     }
     cancelButton_Click(sender, e);
 }
        /// <summary>
        /// Determines whether the <see cref="ICollection{T}"/> contains a specific
        /// value.
        /// </summary>
        /// <remarks>
        /// It <see cref="TryReverse">try reverses</see> the <paramref name="item"/>
        /// and then calls the <see cref="ICollection{T}.Contains"/> method on the source
        /// collection. Otherwise, it iterates through the enumerator returned by
        /// <see cref="IEnumerable{T}.GetEnumerator()"/> method of the source collection,
        /// transform each element and compare it with <paramref name="item"/> until a match is
        /// found.
        /// </remarks>
        /// <returns>
        /// true if item is found in the <see cref="ICollection{T}"/>; otherwise, false.
        /// </returns>
        ///
        /// <param name="item">
        /// The object to locate in the <see cref="ICollection{T}"/>.
        /// </param>
        public override bool Contains(TTo item)
        {
            TFrom result;

            if (TryReverse(item, out result))
            {
                return(SourceCollection.Contains(result));
            }

            foreach (TFrom i in SourceCollection)
            {
                if (Transform(i).Equals(item))
                {
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 4
0
        //****************************************

        /// <summary>
        /// Determines whether the collection contains a specific item
        /// </summary>
        /// <param name="item">The item to locate</param>
        /// <returns>True if the item is in the list, otherwise false</returns>
        public bool Contains(TOutput item)
        {
            // If there's no reversal operation, do it the slow way
            if (_ReverseConversion == null)
            {
                return(Parent.Select(_Conversion).Contains(item));
            }

            var SourceValue = _ReverseConversion(item);

            // If our source implements ICollection, use it and convert back
            if (Parent is ICollection <TInput> SourceCollection)
            {
                return(SourceCollection.Contains(SourceValue));
            }

            // No ICollection, so convert back and search for it the hard way
            return(Enumerable.Contains(Parent, SourceValue));
        }
 /// <summary>
 /// Determines whether the <see cref="ICollection{T}"/> contains a specific
 /// value.
 /// </summary>
 /// <returns>
 /// true if item is found in the <see cref="ICollection{T}"/>; otherwise, false.
 /// </returns>
 ///
 /// <param name="item">
 /// The object to locate in the <see cref="ICollection{T}"/>.
 /// </param>
 public override bool Contains(TBase item)
 {
     return(item is TSub && SourceCollection.Contains((TSub)item));
 }
Exemplo n.º 6
0
 public bool Contains(object value)
 {
     return(value == NullObject || SourceCollection.Contains(value));
 }