Example #1
0
        /// <summary>
        /// Add a select item to the current list of selection items
        /// </summary>
        /// <param name="itemToAdd">The item to add</param>
        internal void AddToSelectedItems(SelectItem itemToAdd)
        {
            ExceptionUtils.CheckArgumentNotNull(itemToAdd, "itemToAdd");

            if (this.selectedItems.Any(x => x is WildcardSelectItem) && IsStructuralOrNavigationPropertySelectionItem(itemToAdd))
            {
                return;
            }

            bool isWildcard = itemToAdd is WildcardSelectItem;

            List <SelectItem> newSelectedItems = new List <SelectItem>();

            foreach (SelectItem selectedItem in this.selectedItems)
            {
                if (isWildcard)
                {
                    if (!IsStructuralSelectionItem(selectedItem))
                    {
                        newSelectedItems.Add(selectedItem);
                    }
                }
                else
                {
                    newSelectedItems.Add(selectedItem);
                }
            }

            newSelectedItems.Add(itemToAdd);
            this.selectedItems = new ReadOnlyCollection <SelectItem>(newSelectedItems);
        }
Example #2
0
        /// <summary>
        /// Get the string representation of a select item (that isn't an expandedNavPropSelectItem
        /// </summary>
        /// <param name="selectedItem">the select item to translate</param>
        /// <returns>the string representation of this select item, or null if the select item is an expandedNavPropSelectItem</returns>
        private static string GetSelectString(SelectItem selectedItem)
        {
            WildcardSelectItem wildcardSelect = selectedItem as WildcardSelectItem;
            NamespaceQualifiedWildcardSelectItem namespaceQualifiedWildcard = selectedItem as NamespaceQualifiedWildcardSelectItem;
            PathSelectItem pathSelectItem = selectedItem as PathSelectItem;

            if (wildcardSelect != null)
            {
                return("*");
            }
            else if (namespaceQualifiedWildcard != null)
            {
                return(namespaceQualifiedWildcard.Namespace + ".*");
            }
            else if (pathSelectItem != null)
            {
                return(String.Join("/", pathSelectItem.SelectedPath.WalkWith(PathSegmentToStringTranslator.Instance).ToArray()));
            }
            else
            {
                return(null);
            }
        }
Example #3
0
        /// <summary>
        /// is this selection item a structural selection item.
        /// </summary>
        /// <param name="selectItem">the selection item to check</param>
        /// <returns>true if this selection item is a structural property selection item.</returns>
        private static bool IsStructuralSelectionItem(SelectItem selectItem)
        {
            PathSelectItem pathSelectItem = selectItem as PathSelectItem;

            return(pathSelectItem != null && (pathSelectItem.SelectedPath.LastSegment is PropertySegment));
        }