예제 #1
0
        public override string GetKnockoutExpression(KnockoutExpressionData data)
        {
            var sb = new StringBuilder();

            sb.Append(Name);
            sb.Append(" : ");
            if (NeedQuotes)
                sb.Append('\'');
            sb.Append(Value);
            if (NeedQuotes)
                sb.Append('\'');

            return sb.ToString();
        }
예제 #2
0
        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();
        }
예제 #3
0
 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;
 }
예제 #4
0
 public abstract string GetKnockoutExpression(KnockoutExpressionData data);
 public void InstanceNamesTest03()
 {
     var data = new KnockoutExpressionData { InstanceNames = new[] { "$parents[1]" } };
     RunTest((Expression<Func<TestViewModel, Action>>)(x => x.Click), "$parents[1].Click", data);
 }
 public void InstanceNamesTest02()
 {
     var data = new KnockoutExpressionData { InstanceNames = new[] { "X", "Y", "Z" } };
     RunTest((Expression<Func<TestViewModel, TestViewModel, TestViewModel, string>>)((x, y, z) => x.A + y.B + z.C), "((X.A()+Y.B())+Z.C())", data);
 }
 public void InstanceNamesTest01()
 {
     var data = new KnockoutExpressionData { InstanceNames = new[] { "$parent" } };
     RunTest((Expression<Func<TestViewModel, string>>)(model => model.A), "$parent.A", data);
 }
 private void RunTest(Expression expression, string expected, KnockoutExpressionData data = null)
 {
     string actual = KnockoutExpressionConverter.Convert(expression, data);
     AssertStringEquivalent(expected, actual);
 }