/// <summary> /// Remove a condition with the specified name from the collection if it exists. /// </summary> /// <param name="conditionName">The unique name of the condition.</param> /// <param name="removeFromCache">If true a cached state of the condition will also be removed from the cache. By default true.</param> public void RemoveCondition(string conditionName, bool removeFromCache = true) { _ratingConditions.Remove(conditionName); if (removeFromCache) { RatingConditionCache.Delete(conditionName); } }
/// <summary> /// Add a condition to the collection. /// </summary> /// <param name="conditionName">The unique name of the condition.</param> /// <param name="condition">The condition instance that will be added to the collection.</param> /// <exception cref="System.ArgumentException">Thrown if a condition with the given name already exists in the collection.</exception> public void AddCondition(string conditionName, IRatingCondition condition) { _ratingConditions.Add(conditionName, condition); if (condition is ICachableCondition cachableCondition && cachableCondition.CacheCurrentValue) { if (!RatingConditionCache.Load(conditionName, cachableCondition)) { RatingConditionCache.Save(conditionName, cachableCondition); } } }