internal static bool BindItemHelper(IOptionItem item, string virtualPropertyName, IOptionGroup group, ISelectionProvider <T> selectionProvider, string prefix, bool addToOptionHandler) { bool retval = false; IOptionItemFilter <T> filter = item.Lookup <IOptionItemFilter <T> >(); string finalName = DefaultOptionBuilderContext <object> .CreatePrefix(prefix, virtualPropertyName); OptionItemValidities validities; if (filter == null) { validities = CheckValidity(new DefaultOptionItemFilter <T>(finalName), selectionProvider); } else { validities = CheckValidity(new DefaultOptionItemFilter <T>(finalName), selectionProvider) & CheckValidity(filter, selectionProvider); } if (validities != OptionItemValidities.Invalid) { CompositeHandler <T> .Create(selectionProvider, finalName, item); if (addToOptionHandler) { group.Items.Add(item); } retval = true; if (validities != OptionItemValidities.ReadWrite) { item.Enabled = false; } } return(retval); }
private static OptionItemValidities CheckValidity(IOptionItemFilter <T> filter, ISelectionProvider <T> selection) { if (filter != null) { return(filter.CheckValidity(selection)); } else { return(OptionItemValidities.ReadWrite); } }