private static string ExpressionToString(Type modelType, Expression expression) { var data = KnockoutExpressionData.CreateConstructorData(); data.Aliases[modelType.FullName] = "this"; return(KnockoutExpressionConverter.Convert(expression, data)); }
private static string GetGetExpression(Type modelType, object model, MethodInfo method) { var expression = method.Invoke(model, null) as Expression; var data = KnockoutExpressionData.CreateConstructorData(); data.Aliases[modelType.FullName] = "this"; return(KnockoutExpressionConverter.Convert(expression, data)); }
public override string GetKnockoutExpression(KnockoutExpressionData data) { if (string.IsNullOrWhiteSpace(Value)) { Value = "$data"; } return($"{Name}: '{Value}'"); }
private string LocalConvert(Expression expression, KnockoutExpressionData convertData = null) { lambdaFrom.Clear(); data = convertData ?? new KnockoutExpressionData(); data = data.Clone(); if (data.InstanceNames == null || data.InstanceNames.Length == 0) data.InstanceNames = new[] { "" }; return GetterSetterCorrecting(Visit(expression)); }
public KnockoutExpressionData Clone() { var data = new KnockoutExpressionData(); if (InstanceNames != null) data.InstanceNames = InstanceNames.Clone() as string[]; if (Aliases != null) foreach (var pair in Aliases) data.Aliases[pair.Key] = pair.Value; data.NeedBracketsForAllMembers = NeedBracketsForAllMembers; return data; }
private string LocalConvert(Expression expression, KnockoutExpressionData convertData = null) { lambdaFrom.Clear(); data = convertData ?? new KnockoutExpressionData(); data = data.Clone(); if (data.InstanceNames == null || data.InstanceNames.Length == 0) { data.InstanceNames = new[] { "" } } ; return(GetterSetterCorrecting(Visit(expression))); }
protected KnockoutExpressionData CreateData() { var data = new KnockoutExpressionData(); if (InstanceNames != null) { data.InstanceNames = InstanceNames; } if (Aliases != null) { data.Aliases = Aliases; } return(data.Clone()); }
public override string GetKnockoutExpression(KnockoutExpressionData data) { string value = KnockoutExpressionConverter.Convert(ExpressionRaw, data); if (string.IsNullOrWhiteSpace(value)) value = "$data"; var sb = new StringBuilder(); sb.Append(Name); sb.Append(" : "); sb.Append(value); return sb.ToString(); }
public override string GetKnockoutExpression(KnockoutExpressionData data) { var builder = new StringBuilder(); builder.Append(Name); builder.Append(" : "); if (NeedQuotes) builder.Append('\''); builder.Append(Value); if (NeedQuotes) builder.Append('\''); return builder.ToString(); }
public override string GetKnockoutExpression(KnockoutExpressionData data) { var sb = new StringBuilder(); sb.Append(Name); sb.Append(" : {"); for (int i = 0; i < subItems.Count; i++) { if (i != 0) sb.Append(","); sb.Append(subItems[i].GetKnockoutExpression(data)); } sb.Append('}'); return sb.ToString(); }
public override string GetKnockoutExpression(KnockoutExpressionData data) { var builder = new StringBuilder(); builder.Append(Name); builder.Append(" : "); if (NeedQuotes) { builder.Append('\''); } builder.Append(Value); if (NeedQuotes) { builder.Append('\''); } return(builder.ToString()); }
public KnockoutExpressionData Clone() { var data = new KnockoutExpressionData(); if (InstanceNames != null) { data.InstanceNames = InstanceNames.Clone() as string[]; } if (Aliases != null) { foreach (var pair in Aliases) { data.Aliases[pair.Key] = pair.Value; } } data.NeedBracketsForAllMembers = NeedBracketsForAllMembers; return(data); }
public override string GetKnockoutExpression(KnockoutExpressionData data) { var builder = new StringBuilder(); builder.Append(Name); builder.Append(": {"); for (int i = 0; i < subItems.Count; i++) { if (i != 0) { builder.Append(", "); } builder.Append(subItems[i].GetKnockoutExpression(data)); } builder.Append('}'); return(builder.ToString()); }
public KnockoutTagBuilder <TModel> DropDownList <TItem>(Expression <Func <TModel, IList <TItem> > > options, object htmlAttributes = null, Expression <Func <TItem, object> > optionsText = null) { var tagBuilder = new KnockoutTagBuilder <TModel>(Context, "select", InstanceNames, Aliases); tagBuilder.ApplyAttributes(htmlAttributes); if (options != null) { tagBuilder.Options(Expression.Lambda <Func <TModel, IEnumerable> >(options.Body, options.Parameters)); } if (optionsText != null) { var data = new KnockoutExpressionData { InstanceNames = new[] { "item" } }; tagBuilder.OptionsText("function(item) { return " + KnockoutExpressionConverter.Convert(optionsText, data) + "; }"); } return(tagBuilder); }
public void InstanceNamesTest01() { var data = new KnockoutExpressionData { InstanceNames = new[] { "$parent" } }; RunTest((Expression<Func<TestModel, string>>)(model => model.A), "$parent.A", data); }
public static string Convert(Expression expression, KnockoutExpressionData convertData = null) { var converter = new KnockoutExpressionConverter(); return(converter.LocalConvert(expression, convertData)); }
public void InstanceNamesTest02() { var data = new KnockoutExpressionData { InstanceNames = new[] { "X", "Y", "Z" } }; RunTest((Expression<Func<TestModel, TestModel, TestModel, string>>)((x, y, z) => x.A + y.B + z.C), "((X.A()+Y.B())+Z.C())", data); }
private void RunTest(Expression expression, string expected, KnockoutExpressionData data = null) { string actual = KnockoutExpressionConverter.Convert(expression, data); AssertStringEquivalent(expected, actual); }
public abstract string GetKnockoutExpression(KnockoutExpressionData data);
public static string Convert(Expression expression, KnockoutExpressionData convertData = null) { var converter = new KnockoutExpressionConverter(); return converter.LocalConvert(expression, convertData); }