///<inheritdoc/>
        public virtual OptionItemValidities CheckValidity(ISelectionProvider <T> selection)
        {
            if (selection.Selection.Count == 0)
            {
                return(OptionItemValidities.Invalid);
            }
            OptionItemValidities retval = OptionItemValidities.ReadWrite;

            foreach (IPropertyItemDescriptor <T> descriptor in selection.Selection)
            {
                IPropertyMap map = descriptor.Properties;
                if (map == null)
                {
                    return(OptionItemValidities.Invalid);
                }
                IPropertyItem item = map.GetEntry(virtualPropertyName);
                if (item != null)
                {
                    IValueGetter getter = item.Getter;
                    IValueSetter setter = item.Setter;

                    if (getter != null && getter.CanGet())
                    {
                        if (setter == null || !setter.CanSet())
                        {
                            //readonly item...
                            retval = OptionItemValidities.ReadOnly;
                        }
                    }
                    else
                    {
                        //we can't even get the values :-(
                        return(OptionItemValidities.Invalid);
                    }
                }
                else
                {
                    return(OptionItemValidities.Invalid);
                }
            }
            return(retval);
        }
        public void UpdateOptionItem(IOptionItem oi)
        {
            if (inUpdate)
            {
                return;
            }
//      if (!optionItem.IsAlive) {
//        return;
//      }
//
//      IOptionItem oi = (IOptionItem)optionItem.Target;
            //lock...
            inUpdate = true;

            ICollection <IPropertyItemDescriptor <T> > descriptors;

            descriptors = selection.Selection;
            if (descriptors.Count == 0)
            {
                SetUndefinedValue(oi);
                inUpdate = false;
                return;
            }
            bool   filled           = false;
            object accumulatedValue = null;


            foreach (IPropertyItemDescriptor <T> descriptor in descriptors)
            {
                //get the propertyItem from the current lookup

                IPropertyMap map = descriptor.Properties;
                if (map == null)
                {
                    continue;
                }
                IPropertyItem item = map.GetEntry(virtualPropertyName);
                if (item == null)
                {
                    continue;
                }
                //get value from current selection item
                IValueGetter getter = item.Getter;
                if (getter == null || !getter.CanGet())
                {
                    continue;
                }

                object value = getter.GetValue();
                if (!filled)
                {
                    //first value
                    accumulatedValue = value;
                    filled           = true;
                }
                else
                {
                    //check if value is different?
                    IEqualityComparer comparer = item.EqualityComparer;
                    if (comparer != null)
                    {
                        if (!comparer.Equals(accumulatedValue, value))
                        {
                            SetUndefinedValue(oi);
                            inUpdate = false;
                            return;
                        }
                    }
                    else
                    {
                        if (accumulatedValue != null && !accumulatedValue.Equals(value))
                        {
                            SetUndefinedValue(oi);
                            inUpdate = false;
                            return;
                        }
                        else if (accumulatedValue == null && value != null)
                        {
                            SetUndefinedValue(oi);
                            inUpdate = false;
                            return;
                        }
                    }
                }
            }
            if (accumulatedValue == null)
            {
                if ((bool)oi.Attributes[OptionItem.SupportNullValueAttribute])
                {
                    oi.Value = accumulatedValue;
                }
            }
            else
            {
                oi.Value = accumulatedValue;
            }
            inUpdate = false;
        }