public void Rebind(THost host, ICollection <TProperty> nullCollection, ICollection <TProperty> collection) { var lazyCollection = collection as LazyEntityCollection <TProperty>; if (lazyCollection != null) { lazyCollection.ItemAdded += x => CollectionProperty.Add(x, _inverse, host); lazyCollection.ItemRemoved += x => CollectionProperty.Remove(x, _inverse, host); } foreach (var x in collection) { CollectionProperty.Add(x, _inverse, host); } }
private static void MergeCollectionProperties(PropertyCollection mergedPropertyCollection, PropertyValue originalProperty, PropertyValue overridingProperty) { CollectionProperty property = (CollectionProperty) originalProperty; CollectionProperty property2 = (CollectionProperty) overridingProperty; CollectionProperty property3 = new CollectionProperty((CollectionPropertyDescriptor) property.PropertyDescriptor); mergedPropertyCollection.Add(property3); foreach (string str in property2.Values) { property3.Add(str); } if (property.Aggregate) { foreach (string str2 in property.Values) { if (!property3.Contains(str2)) { property3.Add(str2); } } } }
/// <summary> /// Merges two collection properties together. /// </summary> /// <param name="mergedPropertyCollection"> /// The merged property collection. /// </param> /// <param name="originalProperty"> /// The original property to merge. /// </param> /// <param name="overridingProperty"> /// The overriding property to merge. /// </param> private static void MergeCollectionProperties(PropertyCollection mergedPropertyCollection, PropertyValue originalProperty, PropertyValue overridingProperty) { Param.AssertNotNull(mergedPropertyCollection, "mergedPropertyCollection"); Param.AssertNotNull(originalProperty, "originalProperty"); Param.AssertNotNull(overridingProperty, "overridingProperty"); CollectionProperty originalCollectionProperty = (CollectionProperty)originalProperty; CollectionProperty overridingCollectionProperty = (CollectionProperty)overridingProperty; // Create a new merged collection property. CollectionProperty mergedCollectionProperty = new CollectionProperty((CollectionPropertyDescriptor)originalCollectionProperty.PropertyDescriptor); mergedPropertyCollection.Add(mergedCollectionProperty); // Add each of the strings from the overriding collection. foreach (string value in overridingCollectionProperty.Values) { mergedCollectionProperty.Add(value); } // If necessary, also add the strings from the original collection. if (originalCollectionProperty.Aggregate) { foreach (string value in originalCollectionProperty.Values) { if (!mergedCollectionProperty.Contains(value)) { mergedCollectionProperty.Add(value); } } } }
public void Rebind(THost host, TProperty previousValue, TProperty value) { CollectionProperty.Remove(previousValue, _inverse, host); CollectionProperty.Add(value, _inverse, host); }