Ejemplo n.º 1
0
        public static Multiton <T> GetInstance(MultitonType mtype)
        {
            if (!Instances.ContainsKey(mtype))
            {
                Instances.Add(mtype, new Multiton <T>());
            }

            return(Instances[mtype]);
        }
Ejemplo n.º 2
0
        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]);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
 private Multiton(MultitonType type)
 {
     this.type = type;
 }