/// <summary> /// 新增商品屬性(如果商品已經存在會覆寫之前屬性設定) /// </summary> /// <param name="property">商品屬性類別</param> /// <param name="dataSource">資料來源名稱</param> public void AddProperty(AbstractProductProperty property, string dataSource = null) { if (dataSource == null) { BasePropertys.AddProperty(property); } else { ProductPropertyList cPropertyList = null; if (!CustomPropertys.TryGetValue(dataSource, out cPropertyList)) { cPropertyList = new ProductPropertyList(); CustomPropertys.Add(dataSource, cPropertyList); } cPropertyList.AddProperty(property); } }
/// <summary> /// 移除商品屬性 /// </summary> /// <param name="symbolId">商品代號</param> /// <param name="dataSource">資料來源名稱</param> public void RemoveProperty(string symbolId, string dataSource = null) { Product cProduct = GetProduct(symbolId); if (dataSource == null) { BasePropertys.RemoveProperty(cProduct); } else { ProductPropertyList cPropertyList = null; if (CustomPropertys.TryGetValue(dataSource, out cPropertyList)) { cPropertyList.RemoveProperty(cProduct); if (cPropertyList.Count == 0) { CustomPropertys.Remove(dataSource); } } } }