Beispiel #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="item">Item stored in the stack</param>
        /// <param name="parent">Parent of this stack</param>
        private TimedScopeStack(TimedScope item, TimedScopeStack parent)
        {
            Code.ExpectsArgument(parent, nameof(parent), TaggingUtilities.ReserveTag(0x23817061 /* tag_96xb7 */));

            Item   = item;
            Parent = parent;
        }
Beispiel #2
0
        /// <summary>
        /// Modify the set of active scopes
        /// </summary>
        /// <param name="addScope">should the scope be added or removed</param>
        private void ModifyActiveScopes(bool addScope)
        {
            TimedScopeStack scopes = TimedScopeStackManager.Scopes;

            if (scopes == null)
            {
                return;
            }

            if (addScope)
            {
                scopes = scopes.Push(this);
            }
            else
            {
                Stack <TimedScope> temporaryScopes = new Stack <TimedScope>();
                while (!scopes.IsRoot)
                {
                    TimedScope popScope;
                    scopes = scopes.Pop(out popScope);
                    if (ReferenceEquals(popScope, this))
                    {
                        break;
                    }

                    temporaryScopes.Push(popScope);
                }

                while (temporaryScopes.Count > 0)
                {
                    scopes = scopes.Push(temporaryScopes.Pop());
                }
            }

            TimedScopeStackManager.Scopes = scopes;
        }