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; }
public static CommandMarkupExpression GetCommandExpressionOrNull(RedwoodProperty property, RedwoodBindable obj) { var value = obj.GetRawValue(property); if (value is CommandMarkupExpression) { return (CommandMarkupExpression)value; } return null; }
public static BindingMarkup GetBindingExpressionOrNull(RedwoodProperty property, RedwoodBindable obj) { var value = obj.GetRawValue(property); if (value is BindingMarkup) { return (BindingMarkup)value; } return null; }
/// <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(); }
/// <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; }
/// <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(); }
protected internal void SetParent(RedwoodBindable parent) { VerifyAccess(); this.parent = parent; }
public object Evaluate(RedwoodBindable redwoodBindable) { // TODO: implementat return null; }
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; }
public override object GetValue(RedwoodBindable target, RedwoodProperty property) { var dataContext = GetDataContext(Source ?? target, property); var result = Path.Evaluate(dataContext); return result; }
public virtual object GetValue(RedwoodBindable target, RedwoodProperty property) { return RedwoodProperty.UnsetValue; }