예제 #1
0
        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);
            }
        }
예제 #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;
            }
        }
예제 #3
0
 protected ContextIntState(ContextIntState other)
 {
     Count = other.Count;
 }