示例#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;
 }