Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Services
- {
- Dictionary<Type, object> _items;
- public Services() => _items = new Dictionary<Type, object>();
- public void Register<T>(T service) => _items[typeof(T)] = service;
- public T Get<T>()
- {
- if (_items.ContainsKey(typeof(T))) return (T)_items[typeof(T)];
- return default;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement