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); }
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)); }
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(); }
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(); }
public string GetProductPreference(ProductPreferences preference) { return(GetProductPreference <string>(preference)); }
public T GetEnumSelectionPreference <T>(ProductPreferences selection) { string enumText = GetProductPreference(selection); return(EnumUtils.StringToEnum <T>(enumText)); }
public void SetEnumSelectionPreference <T>(ProductPreferences selection, T enumVal) { string enumText = EnumUtils.EnumToString <T>(enumVal); SetProductPreference(selection, enumText); }