Example #1
0
        private void AddCausalityStack(CausalityStack s)
        {
            if (Stacks == null)
            {
                Stacks = new List <CausalityStack>(1);
            }
            CausalityStack causalityStack = new CausalityStack();

            if (s.Count > 0)
            {
                CausalityTable = new Dictionary <Guid, ICausality>();
                foreach (ICausality current in s)
                {
                    if (!CausalityTable.ContainsKey(current.Guid))
                    {
                        CausalityTable[current.Guid] = current;
                        causalityStack.Add(current);
                    }
                }
                if (causalityStack.Count > 0)
                {
                    Stacks.Add(causalityStack);
                }
            }
        }
Example #2
0
        internal void AddCausality(ICausality causality)
        {
            if (CausalityThreadContext.IsEmpty(this))
            {
                ActiveCausality = causality;
                return;
            }
            if (CausalityTable == null)
            {
                CausalityTable = new Dictionary <Guid, ICausality>();
            }
            if (ActiveCausality == null)
            {
                if (Stacks != null)
                {
                    if (CausalityTable.ContainsKey(causality.Guid))
                    {
                        return;
                    }
                    CausalityTable.Add(causality.Guid, causality);
                    foreach (CausalityStack current in Stacks)
                    {
                        current.Add(causality);
                    }
                }
                return;
            }
            if (causality.Guid == ActiveCausality.Guid)
            {
                return;
            }
            CausalityTable.Add(ActiveCausality.Guid, ActiveCausality);
            CausalityTable.Add(causality.Guid, causality);
            Stacks = new List <CausalityStack>();
            CausalityStack causalityStack = new CausalityStack();

            causalityStack.Add(ActiveCausality);
            causalityStack.Add(causality);
            ActiveCausality = null;
            Stacks.Add(causalityStack);
        }