public int GetContextStateInt <T>(bool global, int defaultVal) where T : ContextIntState
        {
            ContextIntState countState = global ? GlobalContextStates.GetWithDefault <T>() : ContextStates.GetWithDefault <T>();

            if (countState == null)
            {
                return(defaultVal);
            }
            else
            {
                return(countState.Count);
            }
        }
Beispiel #2
0
        public void AddContextStateInt <T>(int addedVal) where T : ContextIntState
        {
            ContextIntState countState = ContextStates.GetWithDefault <T>();

            if (countState == null)
            {
                T newCount = (T)Activator.CreateInstance(typeof(T));
                newCount.Count = addedVal;
                ContextStates.Set(newCount);
            }
            else
            {
                countState.Count += addedVal;
            }
        }
Beispiel #3
0
 protected ContextIntState(ContextIntState other)
 {
     Count = other.Count;
 }