示例#1
0
        private void Initialize(UIElement root, UIElement element, UIElement innerContext)
        {
            this.root           = root;
            this.element        = element;
            this.innerContext   = innerContext;
            element.bindingNode = this;

            this.lastBeforeUpdateFrame = default;
            this.lastAfterUpdateFrame  = default;
            this.createdBinding        = default;
            this.enabledBinding        = default;
            this.updateBindings        = default;
            this.lateBindings          = default;
            this.localVariable         = default;
            this.parent             = default;
            this.referencedContexts = default;
        }
示例#2
0
        public ContextVariable GetContextVariable(int id)
        {
            ContextVariable ptr = localVariable;

            while (ptr != null)
            {
                if (ptr.id == id)
                {
                    return(ptr.reference ?? ptr);
                }

                ptr = ptr.next;
            }

            // if didnt find a local variable, start a search upwards

            // if found, reference locally. should only hit this once

            if (parent == null)
            {
                UIElement elemPtr = element.parent;
                while (elemPtr != null)
                {
                    if (elemPtr.bindingNode != null)
                    {
                        parent = elemPtr.bindingNode;
                        break;
                    }

                    elemPtr = elemPtr.parent;
                }
            }

            ContextVariable value = parent?.GetContextVariable(id);

            // it is technically an error if we can't find the context variable, something went wrong with compilation
            Debug.Assert(value != null, nameof(value) + " != null");

            value = value.CreateReference();

            CreateLocalContextVariable(value);

            return(value);
        }
示例#3
0
        public void CreateLocalContextVariable(ContextVariable variable)
        {
            if (localVariable == null)
            {
                localVariable = variable;
                return;
            }

            ContextVariable ptr = localVariable;

            while (true)
            {
                if (ptr.next == null)
                {
                    ptr.next = variable;
                    return;
                }

                ptr = ptr.next;
            }
        }