Clover.NET coverage report - Coverage for s2dao.net

Coverage timestamp: 2006年5月30日 11:48:56

File Stats: LOC: 86   Methods: 4
NCLOC: 63 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
Seasar.Dao.Node\ParenBindVariableNode.cs 50.0% 75.0% 75.0% 67.4%
coverage coverage
1   #region Copyright
2   /*
3   * Copyright 2005 the Seasar Foundation and the Others.
4   *
5   * Licensed under the Apache License, Version 2.0 (the "License");
6   * you may not use this file except in compliance with the License.
7   * You may obtain a copy of the License at
8   *
9   * http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14   * either express or implied. See the License for the specific language
15   * governing permissions and limitations under the License.
16   */
17   #endregion
18  
19   using System;
20   using System.Collections;
21  
22   namespace Seasar.Dao.Node
23   {
24   public class ParenBindVariableNode : AbstractNode
25   {
26   private string bindName;
27   private string expression;
28  
29 18 public ParenBindVariableNode(string expression)
30   {
31 18 this.bindName = expression;
32 18 this.expression = "self.GetArg('" + expression + "')";
33   }
34  
35 0 public string Expression
36   {
37   get { return expression; }
38   }
39  
40 5 public override void Accept(ICommandContext ctx)
41   {
42 5 object var = InvokeExpression(expression, ctx);
43 5 if(var != null)
44   {
45 5 IList list = var as IList;
46 5 Array array = new object[list.Count];
47 5 list.CopyTo(array, 0);
48 5 BindArray(ctx, array);
49   }
50 0 else if(var == null)
51   {
52   return;
53   }
54   else if(var.GetType().IsArray)
55   {
56   BindArray(ctx, var);
57   }
58   else
59   {
60   ctx.AddSql(var, var.GetType(), bindName);
61   }
62   }
63  
64 5 private void BindArray(ICommandContext ctx, object arrayArg)
65   {
66 5 object[] array = arrayArg as object[];
67 5 int length = array.Length;
68 0 if(length == 0) return;
69 5 Type type = null;
70 23 for(int i = 0; i < length; ++i)
71   {
72 18 object o = array[i];
73 18 if(o != null) type = o.GetType();
74   }
75 5 ctx.AddSql("(");
76 5 ctx.AddSql(array[0], type, bindName + 1);
77 18 for(int i = 1; i < length; ++i)
78   {
79 13 ctx.AppendSql(array[i], type, bindName + (i + 1));
80   }
81 5 ctx.AddSql(")");
82   }
83  
84   }
85   }
86