public void Dispose()
 {
     if (ThreadData.Contains(Key))
     {
         var stack = ThreadData.GetClass <Stack <string> >(Key);
         stack.Pop();
         ThreadData.SetValue(Key, stack);
     }
 }
Esempio n. 2
0
        public static int GetCounter()
        {
            var counter = 0;

            if (ThreadData.Contains(CalledKey))
            {
                counter = (int)ThreadData.GetValue <int>(CalledKey);
            }
            return(counter);
        }
        public override ModelCounter GetModelCounter()
        {
            ModelCounter counter;

            if (!ThreadData.Contains(_modelCounterKey))
            {
                ThreadData.SetValue(_modelCounterKey, new ModelCounter());
            }
            counter = ThreadData.GetValue <ModelCounter>(_modelCounterKey);
            return(counter);
        }
            public DepthCheck(int maxDepth, Type type)
            {
                Stack <string> stack = new Stack <string>();

                if (ThreadData.Contains(Key))
                {
                    stack = ThreadData.GetClass <Stack <string> >(Key);
                }
                stack.Push(type.FullName);
                if (stack.Count > maxDepth)
                {
                    throw new MapperStackException(Constants.Errors.LazyLoop.Formatted(
                                                       stack.Aggregate((x, y) => "{0}{1}\n\r".Formatted(x, y))
                                                       ));
                }
                ThreadData.SetValue(Key, stack);
            }