예제 #1
0
        public void SetKeyValue(string key, string value)
        {
            bool IsMatch(PointOfSaleKeyValue posKv) => string.Equals(posKv.Key, key, StringComparison.OrdinalIgnoreCase);

            var cnt = KeyValues.Count(IsMatch);

            if (cnt > 1)
            {
                foreach (var kv in KeyValues.Where(IsMatch).ToArray())
                {
                    KeyValues.Remove(kv);
                }
            }
            else if (cnt == 1)
            {
                KeyValues.First(IsMatch).SetValue(value);
            }
            else
            {
                KeyValues.Add(new PointOfSaleKeyValue(key, value));
            }
        }