public static Multiton <T> GetInstance(MultitonType mtype) { if (!Instances.ContainsKey(mtype)) { Instances.Add(mtype, new Multiton <T>()); } return(Instances[mtype]); }
public static Multiton GetInstance(MultitonType type) { // Lazy init (not thread safe as written) // Recommend using Double Check Loking if needing thread safety if (!_instances.ContainsKey(type)) { _instances.Add(type, new Multiton()); } return(_instances[type]); }
public static Multiton GetInstance(MultitonType type) { // Lazy init (not thread safe as written) // Recommend using Double Check Locking if needing thread safety if (!instances.TryGetValue(type, out var instance)) { instance = new Multiton(type); instances.Add(type, instance); } return(instance); }
private Multiton(MultitonType type) { this.type = type; }