public void Update(string key, int value) { lock (_lockObjContent) { if (!IsValidExistingName(_contents.IntProperties, key, out string errorMessage)) { LogError(errorMessage); return; } _contents.IntProperties[MatsUtils.NormalizeValidPropertyName(key, out errorMessage)] = value; } }
public void Add(string key, bool value) { lock (_lockObjContent) { if (!IsNameValidForAdd(key, _contents, out string errorMessage)) { LogError(errorMessage); return; } _contents.BoolProperties[MatsUtils.NormalizeValidPropertyName(key, out errorMessage)] = value; } }
private bool IsValidExistingName <T>(ConcurrentDictionary <string, T> map, string key, out string errorMessage) { errorMessage = string.Empty; if (!MatsUtils.IsValidPropertyName(key, out errorMessage)) { return(false); } if (!map.ContainsKey(MatsUtils.NormalizeValidPropertyName(key, out errorMessage))) { errorMessage = string.Format(CultureInfo.InvariantCulture, "Property '{0}' does not exist in the property map", key); return(false); } return(true); }
public void Min(string key, long value) { lock (_lockObjContent) { bool containsProperty = IsValidExistingName(_contents.Int64Properties, key, out string errorMessage); if (!containsProperty && !IsNameValidForAdd(key, _contents, out errorMessage)) { LogError(_error + "Min: " + key); return; } if ((containsProperty && _contents.Int64Properties[MatsUtils.NormalizeValidPropertyName(key, out errorMessage)] > value) || !containsProperty) { _contents.Int64Properties[MatsUtils.NormalizeValidPropertyName(key, out errorMessage)] = value; } } }
public void Sum(string key, long value) { lock (_lockObjContent) { if (!IsValidExistingName(_contents.Int64Properties, key, out string errorMessage) && !IsNameValidForAdd(key, _contents, out errorMessage)) { LogError(_error + "Sum: " + key); return; } string idx = MatsUtils.NormalizeValidPropertyName(key, out errorMessage); if (_contents.Int64Properties.ContainsKey(idx)) { _contents.Int64Properties[idx] += value; } else { _contents.Int64Properties[idx] = value; } } }