Beispiel #1
0
        public static AsyncObservableCollection <T> GetItems <T>(this AsyncObservableCollection <T> collection, DummyItemType collectionType) where T : StoreItem, new()
        {
            AsyncObservableCollection <T> items = collection.ToCollection();

            items.Sort((x, y) => x.Title.CompareTo(y.Title));

            if (collectionType == DummyItemType.NoneType || collectionType == DummyItemType.AllNoneType)
            {
                T item = StoreItem.GetDummyItem <T>(DummyItemType.NoneType);
                items.Insert(0, item);
            }

            if (collectionType == DummyItemType.AllType || collectionType == DummyItemType.AllNoneType)
            {
                T item = StoreItem.GetDummyItem <T>(DummyItemType.AllType);
                items.Insert(0, item);
            }

            // If there are no items at all in the collection, throw an 'All' on the list
            if (items.Count == 0)
            {
                T item = StoreItem.GetDummyItem <T>(DummyItemType.AllType);
                items.Insert(0, item);
            }

            return(items);
        }
Beispiel #2
0
        //------------------------------------------------------------------------------------
        /// <summary>
        /// Returns a list of all the allowed values for the given Product Studio field.  This
        /// assumes that this property does not depend on the value of any other property for
        /// its state.
        /// </summary>
        //------------------------------------------------------------------------------------
        public virtual AsyncObservableCollection <AllowedValue> GetFieldAllowedValues(string propName, AllowedValue firstValue = null)
        {
            AsyncObservableCollection <AllowedValue> allowedValues = GetFieldAllowedValues(CreateDSItem(), propName);

            if (allowedValues.Count == 0)
            {
                if (FieldAllowedValues.ContainsKey(propName))
                {
                    allowedValues = FieldAllowedValues[propName];
                }
            }

            if (firstValue != null)
            {
                allowedValues.Insert(0, firstValue);
            }

            return(allowedValues);
        }