| 12345678910111213141516171819202122232425262728293031323334353637 |
- using System.Collections.Generic;
- namespace Quadarax.Foundation.Core.Value
- {
- public class ValidatorContext
- {
- private readonly IDictionary<string, object?> _context = new Dictionary<string, object?>();
- public ValidatorContext()
- {
- }
- public ValidatorContext(IEnumerable<KeyValuePair<string, object?>> initialContext)
- {
- foreach (var item in initialContext)
- {
- _context.Add(item);
- }
- }
- public TValue? GetValue<TValue>(string key)
- {
- return (TValue?) _context[key];
- }
- public void SetValue<TValue>(string key, TValue value)
- {
- if (!_context.TryAdd(key, value))
- _context[key] = value;
- }
- public bool Exists(string key)
- {
- return _context.ContainsKey(key);
- }
- }
- }
|