示例#1
0
        public ItemType GetItemSelectionPreference <ItemType>(ProductPreferences selection) where ItemType : StoreItem
        {
            string productKey = Planner.Instance.CurrentProductGroupKey;

            if (ProductPreferences.ContainsKey(productKey))
            {
                Dictionary <ProductPreferences, object> itemSelectionPreferences = ProductPreferences[productKey];
                if (itemSelectionPreferences.ContainsKey(selection))
                {
                    string storeKey = (string)itemSelectionPreferences[selection];
                    return(Planner.Instance.ItemRepository.GetItem <ItemType>(storeKey));
                }
            }
            return(null);
        }
示例#2
0
        public T GetProductPreference <T>(ProductPreferences preferenceSelector)
        {
            if (Planner.Instance.CurrentProductGroup != null)
            {
                string productKey = Planner.Instance.CurrentProductGroup.StoreKey;
                if (ProductPreferences.ContainsKey(productKey))
                {
                    Dictionary <ProductPreferences, object> productPreferences = ProductPreferences[productKey];
                    if (productPreferences.ContainsKey(preferenceSelector))
                    {
                        return((T)productPreferences[preferenceSelector]);
                    }
                }
            }

            return(default(T));
        }
示例#3
0
        public void SetProductPreference(ProductPreferences preference, object value)
        {
            string productKey = Planner.Instance.CurrentProductGroupKey;

            if (!ProductPreferences.ContainsKey(productKey))
            {
                ProductPreferences.Add(productKey, new Dictionary <ProductPreferences, object>());
            }

            Dictionary <ProductPreferences, object> productPreferences = ProductPreferences[productKey];

            if (!productPreferences.ContainsKey(preference))
            {
                productPreferences.Add(preference, null);
            }

            productPreferences[preference] = value;
            Serialize();
        }
示例#4
0
        public void SetItemSelectionPreference(ProductPreferences selection, StoreItem item)
        {
            if (selection == PlannerNameSpace.ProductPreferences.None)
            {
                return;
            }

            string productKey = Planner.Instance.CurrentProductGroupKey;

            if (!ProductPreferences.ContainsKey(productKey))
            {
                ProductPreferences.Add(productKey, new Dictionary <ProductPreferences, object>());
            }

            Dictionary <ProductPreferences, object> itemSelectionPreferences = ProductPreferences[productKey];

            if (!itemSelectionPreferences.ContainsKey(selection))
            {
                itemSelectionPreferences.Add(selection, null);
            }

            itemSelectionPreferences[selection] = item == null ? null : item.StoreKey;
            Serialize();
        }
示例#5
0
 public string GetProductPreference(ProductPreferences preference)
 {
     return(GetProductPreference <string>(preference));
 }
示例#6
0
        public T GetEnumSelectionPreference <T>(ProductPreferences selection)
        {
            string enumText = GetProductPreference(selection);

            return(EnumUtils.StringToEnum <T>(enumText));
        }
示例#7
0
        public void SetEnumSelectionPreference <T>(ProductPreferences selection, T enumVal)
        {
            string enumText = EnumUtils.EnumToString <T>(enumVal);

            SetProductPreference(selection, enumText);
        }