public Multiplier GetContextStateMult <T>(bool global, Multiplier defaultVal) where T : ContextMultState
        {
            ContextMultState countState = global ? GlobalContextStates.GetWithDefault <T>() : ContextStates.GetWithDefault <T>();

            if (countState == null)
            {
                return(defaultVal);
            }
            else
            {
                return(countState.Mult);
            }
        }
        public void AddContextStateMult <T>(bool global, int numerator, int denominator) where T : ContextMultState
        {
            ContextMultState multState = global ? GlobalContextStates.GetWithDefault <T>() : ContextStates.GetWithDefault <T>();

            if (multState == null)
            {
                T newMult = (T)Activator.CreateInstance(typeof(T));
                newMult.Mult = new Multiplier(numerator, denominator);
                if (global)
                {
                    GlobalContextStates.Set(newMult);
                }
                else
                {
                    ContextStates.Set(newMult);
                }
            }
            else
            {
                multState.Mult.AddMultiplier(numerator, denominator);
            }
        }
Exemple #3
0
 protected ContextMultState(ContextMultState other)
 {
     Mult = other.Mult;
 }