コード例 #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
ファイル: KnockoutBindingItem.cs プロジェクト: hernangm/punch
 public abstract string GetKnockoutExpression(KnockoutExpressionData data);
コード例 #5
0
 public void InstanceNamesTest03()
 {
     var data = new KnockoutExpressionData { InstanceNames = new[] { "$parents[1]" } };
     RunTest((Expression<Func<TestViewModel, Action>>)(x => x.Click), "$parents[1].Click", data);
 }
コード例 #6
0
 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);
 }
コード例 #7
0
 public void InstanceNamesTest01()
 {
     var data = new KnockoutExpressionData { InstanceNames = new[] { "$parent" } };
     RunTest((Expression<Func<TestViewModel, string>>)(model => model.A), "$parent.A", data);
 }
コード例 #8
0
 private void RunTest(Expression expression, string expected, KnockoutExpressionData data = null)
 {
     string actual = KnockoutExpressionConverter.Convert(expression, data);
     AssertStringEquivalent(expected, actual);
 }