// PUBLIC METHODS

    public N Create <N>(S id, T owner) where N : GuiComponent <T>, new()
    {
        if (m_Pairs.ContainsKey(id) == true)
        {
            Debug.LogError("GuiComponentContainer<" + typeof(T).Name + ">.Create() :: Attempt to create duplicated component " + typeof(N).Name +
                           "<" + id + ">");
            return(null);
        }

        N component = new N();

        if (component == null)
        {
            Debug.LogError("GuiComponentContainer<" + typeof(T).Name + ">.Create() :: Can't create component " + typeof(N).Name + "<" + id + ">");
            return(null);
        }

        component.Init(owner);
        if (component.IsInitialized == false)
        {
            Debug.LogError("GuiComponentContainer<" + typeof(T).Name + ">.Create() :: Can't initialize component " + typeof(N).Name + "<" + id +
                           ">");
            return(null);
        }

        m_Pairs[id] = component;

        return(component);
    }
Esempio n. 2
0
        public void Init()
        {
            for (int i = 0; i < Template.Length; i++)
            {
                // add in template characters
                char ch = Template[i];
                if (Elems.ContainsKey(ch))
                {
                    Elems[ch]++;
                }
                else
                {
                    Elems.Add(ch, 1);
                }
            }

            // add in pairs
            for (int i = 0; i < Template.Length - 1; i++)
            {
                var key = Template.Substring(i, 2);
                if (Pairs.ContainsKey(key))
                {
                    Pairs[key]++;
                }
                else
                {
                    Pairs.Add(key, 1);
                }
            }
        }
Esempio n. 3
0
 /// <summary>Enumerate all candle data and time frames provided by this exchange</summary>
 protected override IEnumerable <PairAndTF> EnumAvailableCandleDataInternal(TradePair pair)
 {
     if (pair != null)
     {
         var cp = new CurrencyPair(pair.Base, pair.Quote);
         if (!Pairs.ContainsKey(pair.UniqueKey))
         {
             yield break;
         }
         foreach (var mp in Enum <EMarketPeriod> .Values)
         {
             yield return(new PairAndTF(pair, ToTimeFrame(mp)));
         }
     }
     else
     {
         foreach (var p in Pairs)
         {
             foreach (var mp in Enum <EMarketPeriod> .Values)
             {
                 yield return(new PairAndTF(p, ToTimeFrame(mp)));
             }
         }
     }
 }
Esempio n. 4
0
        public string GetValForKey(string InKey)
        {
            if (Pairs.ContainsKey(InKey))
            {
                return(Pairs[InKey]);
            }

            return("");
        }
Esempio n. 5
0
        public override T Get(string name)
        {
            if (!Pairs.ContainsKey(name))
            {
                Pairs.Add(name, base.Get(name));
            }

            return(Pairs[name]);
        }
Esempio n. 6
0
 public PairConfig this[string key]
 {
     get
     {
         if (!Pairs.ContainsKey(key))
         {
             Pairs.Add(key, new PairConfig());
         }
         return(Pairs[key]);
     }
 }
Esempio n. 7
0
        internal void WriteToScoreboard(string userInput, Yatzy spil, bool AddToPossibleOutcomesInstead = false)
        {
            int[] countOfEachDice = spil.CountOfEachDice();

            if (spil.RoundCounter < 6) //altså når man spiller i upper section.
            {
                if (SingleNumberNumeric.ContainsKey(userInput))
                {
                    AddUpperToScoreboard(userInput, countOfEachDice, AddToPossibleOutcomesInstead);
                }
            }

            else //lower section
            {//ikke et switch statement fordi fx addPairToScoreboard er nemmere at samle som enkelt i stedet for flere forskellige cases i et swtich.
             //man kan nemlig ikke sige  case 1,2,3:    man kan kun sige case 1:    case 2:   osv.       Så det er for at undgå at gentage kode.
                if (Pairs.ContainsKey(userInput))
                {
                    AddPairToScoreboard(userInput, countOfEachDice, AddToPossibleOutcomesInstead);
                }

                else if (OfAKind.ContainsKey(userInput))
                {
                    AddOfAKindToScoreboard(userInput, countOfEachDice, AddToPossibleOutcomesInstead);
                }

                else if (Straight.ContainsKey(userInput))
                {
                    AddStraightToScoreboard(userInput, countOfEachDice, AddToPossibleOutcomesInstead);
                }

                else if (userInput == "fuldt hus")
                {
                    AddFuldHusToScoreboard(userInput, countOfEachDice, AddToPossibleOutcomesInstead);
                }

                else if (userInput == "yatzy")
                {
                    AddYatzyToScoreboard(userInput, countOfEachDice, AddToPossibleOutcomesInstead);
                }

                else if (userInput == "chance")
                {
                    AddChanceToScoreboard(userInput, countOfEachDice, AddToPossibleOutcomesInstead);
                }
            }
        }
Esempio n. 8
0
        public override T Get(string name)
        {
            if (!Pairs.ContainsKey(name))
            {
                var t = base.Get(name);
                Pairs.Add(name, t);

                if (t is BaseDbContext dbContext)
                {
                    if (Configuration["migration:enabled"] == "true")
                    {
                        dbContext.Migrate();
                    }
                }
            }

            return(Pairs[name]);
        }