Пример #1
0
 public BindingExpression(BindingMode mode, Binding.Parsing.Expressions.BindingPathExpression path, RedwoodProperty sourceProperty = null, RedwoodBindable source = null)
 {
     Path = path;
     Mode = mode;
     SourceProperty = sourceProperty ?? Controls.RedwoodControl.DataContextProperty;
     Source = source;
 }
Пример #2
0
        public static CommandMarkupExpression GetCommandExpressionOrNull(RedwoodProperty property, RedwoodBindable obj)
        {
            var value = obj.GetRawValue(property);
            if (value is CommandMarkupExpression)
            {
                return (CommandMarkupExpression)value;
            }

            return null;
        }
Пример #3
0
        public static BindingMarkup GetBindingExpressionOrNull(RedwoodProperty property, RedwoodBindable obj)
        {
            var value = obj.GetRawValue(property);
            if (value is BindingMarkup)
            {
                return (BindingMarkup)value;
            }

            return null;
        }
Пример #4
0
        /// <summary>
        /// Translates to knockout property.
        /// </summary>
        public static string TranslateToKnockoutProperty(RedwoodBindable target, RedwoodProperty property, BindingMarkup binding)
        {
            var path = binding.Path;

            // TODO: support for other than two-way modes

            var sb = new StringBuilder();
            var result = TranslateToKnockoutProperty(path, sb, allowConstants: false);
            if (result != null)
            {
                ThrowBindingContainsUnsupportedExpression();
            }
            return sb.ToString();
        }
Пример #5
0
 /// <summary>
 /// Gets the chain of data context property values.
 /// </summary>
 private static Stack<Tuple<RedwoodBindable, BindingMarkup>> GetDataContextBindingChain(RedwoodBindable control)
 {
     var parents = new Stack<Tuple<RedwoodBindable, BindingMarkup>>();
     while (control != null)
     {
         var binding = (BindingMarkup)control.GetRawValue(RedwoodControl.DataContextProperty, true);
         if (binding != null)
         {
             parents.Push(new Tuple<RedwoodBindable, BindingMarkup>(control, binding));
         }
         control = control.Parent;
     }
     return parents;
 }
Пример #6
0
        /// <summary>
        /// Builds the path.
        /// </summary>
        public string BuildPath(RedwoodBindable control)
        {
            var parents = GetDataContextBindingChain(control);

            var sb = new StringBuilder();
            while (parents.Count > 0)
            {
                var item = parents.Pop();

                if (sb.Length > 0)
                {
                    sb.Append(".");
                }
                sb.Append(KnockoutBindingHelper.TranslateToKnockoutProperty(item.Item1, RedwoodControl.DataContextProperty, item.Item2));
            }

            return sb.ToString();
        }
Пример #7
0
 protected internal void SetParent(RedwoodBindable parent)
 {
     VerifyAccess();
     this.parent = parent;
 }
Пример #8
0
 public object Evaluate(RedwoodBindable redwoodBindable)
 {
     // TODO: implementat
     return null;
 }
Пример #9
0
        private object GetDataContext(RedwoodBindable target, RedwoodProperty property)
        {
            object result = null;
            bool isDataContextBinding = (property == SourceProperty);

            if (isDataContextBinding)
            {
                // if this is binding on "DataContext" - read value from parent
                if (target.Parent != null)
                    result = target.Parent.GetRawValue(SourceProperty);
            }
            else
            {
                result = target.GetValue(SourceProperty);
            }

            return result;
        }
Пример #10
0
        public override object GetValue(RedwoodBindable target, RedwoodProperty property)
        {
            var dataContext = GetDataContext(Source ?? target, property);

            var result = Path.Evaluate(dataContext);
            return result;
        }
Пример #11
0
 public virtual object GetValue(RedwoodBindable target, RedwoodProperty property)
 {
     return RedwoodProperty.UnsetValue;
 }