Exemple #1
0
        /// <summary>
        /// Processes the control tree.
        /// </summary>
        private void ProcessControlTreeCore(DotvvmControl control, Action <DotvvmControl> action)
        {
            // if there is a DataContext binding, locate the correct token
            var hasDataContext = false;
            var pathValue      = control.GetValue(Internal.PathFragmentProperty, false);

            if (pathValue != null)
            {
                CurrentPath.Push(pathValue as string);
                RefreshCurrentPathArray();
                hasDataContext = true;
            }
            else
            {
                var binding = control.GetValueBinding(DotvvmBindableObject.DataContextProperty, false);
                if (binding != null)
                {
                    CurrentPath.Push(binding.GetKnockoutBindingExpression());
                    RefreshCurrentPathArray();
                    hasDataContext = true;
                }
            }

            action(control);

            // go through all children
            foreach (var child in control.GetChildren())
            {
                ProcessControlTreeCore(child, action);
            }

            if (hasDataContext)
            {
                CurrentPath.Pop();
                RefreshCurrentPathArray();
            }
        }