/// <summary> /// Sets the value to <c>checkState</c> for specified key /// </summary> /// <param name="vl">The vl.</param> /// <param name="checkState">if set to <c>true</c> [check state].</param> /// <param name="logic">The logic.</param> /// <param name="expandAllow">if set to <c>true</c> it will add the <c>vl</c> in the list, if it is not already inside</param> /// <returns></returns> public Boolean Set(T vl, Boolean checkState, checkListLogic logic = checkListLogic.OR, Boolean expandAllow = false) { if (!items.ContainsKey(vl)) { if (expandAllow) { items.Add(vl, checkState); } } else { switch (logic) { case checkListLogic.AND: items[vl] = items[vl] && checkState; break; case checkListLogic.NOR: items[vl] = !(items[vl] || checkState); break; case checkListLogic.NOT: items[vl] = items[vl] && !checkState; break; case checkListLogic.OR: items[vl] = items[vl] && checkState; break; } } return(items[vl]); }
/// <summary> /// Sets the values specified according to <c>check state</c>, only instances that are in the list are set - it will not add any new instance /// </summary> /// <param name="testValues">The test values.</param> /// <param name="checkState">if set to <c>true</c> [check state].</param> /// <param name="logic">The logic.</param> public void Set(IEnumerable <T> testValues, Boolean checkState, checkListLogic logic = checkListLogic.AND) { foreach (T vl in testValues) { if (items.ContainsKey(vl)) { Set(vl, checkState, logic); } } }