Пример #1
0
 public Flyweight GetByKey(char key)
 {
     // Uses "lazy initialization"
       Flyweight valueByKay = null;
       if (_initialized.ContainsKey(key))
       {
     valueByKay = _initialized[key];
       }
       else
       {
     switch (key)
     {
       case 'A': valueByKay = new FlyweightForAImpl(); break;
       case 'B': valueByKay = new FlyweightForBImpl(); break;
       //...
       case 'Z': valueByKay = new FlyweightForZImpl(); break;
     }
     _initialized.Add(key, valueByKay);
       }
       return valueByKay;
 }
Пример #2
0
        public Flyweight GetByKey(char key)
        {
            // Uses "lazy initialization"
            Flyweight valueByKay = null;

            if (_initialized.ContainsKey(key))
            {
                valueByKay = _initialized[key];
            }
            else
            {
                switch (key)
                {
                case 'A': valueByKay = new FlyweightForAImpl(); break;

                case 'B': valueByKay = new FlyweightForBImpl(); break;

                //...
                case 'Z': valueByKay = new FlyweightForZImpl(); break;
                }
                _initialized.Add(key, valueByKay);
            }
            return(valueByKay);
        }