Ejemplo n.º 1
0
        /// <summary>
        /// Add a select item to the current list of selection items
        /// </summary>
        /// <param name="itemToAdd">The item to add</param>
        /// <param name="getOnlySubset">A boolean value indicating whether to get subset only</param>
        internal void AddToSelectedItems(SelectItem itemToAdd, bool getOnlySubset = false)
        {
            ExceptionUtils.CheckArgumentNotNull(itemToAdd, "itemToAdd");

            WildcardSelectItem wildcardSelectItem = this.selectedItems.OfType <WildcardSelectItem>().FirstOrDefault();

            if (wildcardSelectItem != null && IsStructuralOrNavigationPropertySelectionItem(itemToAdd))
            {
                wildcardSelectItem.AddSubsumed(itemToAdd);
                return;
            }

            wildcardSelectItem = itemToAdd as WildcardSelectItem;
            if (wildcardSelectItem != null)
            {
                List <SelectItem> newSelectedItems = new List <SelectItem>();

                foreach (SelectItem selectedItem in this.selectedItems)
                {
                    if (!IsStructuralSelectionItem(selectedItem))
                    {
                        newSelectedItems.Add(selectedItem);
                    }
                    else if (getOnlySubset)
                    {
                        var pathItem = selectedItem as PathSelectItem;
                        if (pathItem != null && pathItem.SelectAndExpand != null)
                        {
                            newSelectedItems.Add(selectedItem);
                        }
                        else
                        {
                            wildcardSelectItem.AddSubsumed(selectedItem);
                        }
                    }
                    else
                    {
                        wildcardSelectItem.AddSubsumed(selectedItem);
                    }
                }

                this.selectedItems = newSelectedItems;
            }

            this.selectedItems.Add(itemToAdd);
        }
Ejemplo n.º 2
0
        private static void AddToSelectedItems(SelectItem itemToAdd, List <SelectItem> selectItems)
        {
            if (itemToAdd == null)
            {
                return;
            }

            // ignore all property selection if there's a wildcard select item.
            WildcardSelectItem wildcardSelectItem = selectItems.OfType <WildcardSelectItem>().FirstOrDefault();

            if (wildcardSelectItem != null && IsStructuralOrNavigationPropertySelectionItem(itemToAdd))
            {
                wildcardSelectItem.AddSubsumed(itemToAdd);
                return;
            }

            // if the selected item is a nav prop, then see if its already there before we add it.
            PathSelectItem pathSelectItem = itemToAdd as PathSelectItem;

            if (pathSelectItem != null)
            {
                NavigationPropertySegment trailingNavPropSegment = pathSelectItem.SelectedPath.LastSegment as NavigationPropertySegment;
                if (trailingNavPropSegment != null)
                {
                    if (selectItems.OfType <PathSelectItem>().Any(i => i.SelectedPath.Equals(pathSelectItem.SelectedPath)))
                    {
                        return;
                    }
                }
            }

            // if the selected item is "*", filter the existing property selection.
            wildcardSelectItem = itemToAdd as WildcardSelectItem;
            if (wildcardSelectItem != null)
            {
                List <SelectItem> shouldFilter = selectItems.Where(s => IsStructuralSelectionItem(s)).ToList();
                wildcardSelectItem.AddSubsumed(shouldFilter);
                foreach (var filterItem in shouldFilter)
                {
                    selectItems.Remove(filterItem);
                }
            }

            selectItems.Add(itemToAdd);
        }
        /// <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);
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Handle a WildcardSelectItem
 /// </summary>
 /// <param name="item">the item to Handle</param>
 public virtual void Handle(WildcardSelectItem item)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Translate a WildcardSelectItem
 /// </summary>
 /// <param name="item">the item to Translate</param>
 /// <returns>Defined by the implementer</returns>
 public virtual T Translate(WildcardSelectItem item)
 {
     throw new NotImplementedException();
 }