using System; using System.Collections.Generic; namespace Gaia.FullSerializer { public sealed class fsContext { private readonly Dictionary _contextObjects = new Dictionary(); public void Reset() { _contextObjects.Clear(); } public void Set(T obj) { _contextObjects[typeof(T)] = obj; } public bool Has() { return _contextObjects.ContainsKey(typeof(T)); } public T Get() { if (_contextObjects.TryGetValue(typeof(T), out var value)) { return (T)value; } throw new InvalidOperationException("There is no context object of type " + typeof(T)); } } }