Clover.NET coverage report - Coverage for s2container.net

Coverage timestamp: 2006年5月30日 11:21:29

File Stats: LOC: 177   Methods: 22
NCLOC: 134 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
Seasar.Extension.ADO\Impl\DataSourceImpl.cs 50.0% 45.8% 50.0% 47.2%
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.Data;
21   using System.Reflection;
22   using Seasar.Framework.Util;
23   using Seasar.Extension.ADO.Types;
24  
25   namespace Seasar.Extension.ADO.Impl
26   {
27   /// <summary>
28   /// DataSourceImpl の概要の説明です。
29   /// </summary>
30   public class DataSourceImpl : IDataSource
31   {
32   private DataProvider provider_;
33   private string connectionString_;
34  
35 45 public DataSourceImpl()
36   {
37   }
38  
39 0 public DataSourceImpl(DataProvider provider, string connectionString)
40   {
41   provider_ = provider;
42   connectionString_ = connectionString;
43   }
44  
45   public DataProvider DataProvider
46   {
47 45 set { provider_ = value; }
48 0 get { return provider_; }
49   }
50  
51   public string ConnectionString
52   {
53 45 set { connectionString_ = value; }
54 0 get { return connectionString_; }
55   }
56  
57   #region IDataSource メンバ
58  
59 49 public System.Data.IDbConnection GetConnection()
60   {
61 49 IDbConnection cn = (IDbConnection) ClassUtil.NewInstance(ForName(provider_.ConnectionType));
62 49 cn.ConnectionString = connectionString_;
63 49 return cn;
64   }
65  
66 11 public System.Data.IDbCommand GetCommand()
67   {
68 11 return (IDbCommand) ClassUtil.NewInstance(ForName(provider_.CommandType));
69   }
70  
71 11 public System.Data.IDbCommand GetCommand(string cmdText)
72   {
73 11 IDbCommand cmd = this.GetCommand();
74 11 cmd.CommandText = cmdText;
75 11 return cmd;
76   }
77  
78 11 public System.Data.IDbCommand GetCommand(string cmdText, System.Data.IDbConnection connection)
79   {
80 11 IDbCommand cmd = this.GetCommand(cmdText);
81 11 cmd.Connection = connection;
82 11 return cmd;
83   }
84  
85 0 public System.Data.IDbCommand GetCommand(string cmdText,
86   System.Data.IDbConnection connection, System.Data.IDbTransaction transaction)
87   {
88   IDbCommand cmd = this.GetCommand(cmdText, connection);
89   cmd.Transaction = transaction;
90   return cmd;
91   }
92  
93 2 public System.Data.IDataParameter GetParameter()
94   {
95 2 return (IDataParameter) ClassUtil.NewInstance(ForName(provider_.ParameterType));
96   }
97  
98 0 public System.Data.IDataParameter GetParameter(string name, System.Data.DbType dataType)
99   {
100   IDataParameter param = this.GetParameter();
101   param.ParameterName = name;
102   param.DbType = dataType;
103   return param;
104   }
105  
106 2 public System.Data.IDataParameter GetParameter(string name, object value)
107   {
108 2 IDataParameter param = this.GetParameter();
109 2 param.ParameterName = name;
110 2 if(value == null)
111   {
112 0 param.Value = DBNull.Value;
113   }
114   else
115   {
116 2 param.Value = value;
117   }
118 2 return param;
119   }
120  
121 0 public System.Data.IDataParameter GetParameter(string name, System.Data.DbType dataType, int size)
122   {
123   Type[] argTypes = new Type[] { typeof(string), typeof(DbType), typeof(int) };
124   ConstructorInfo constructor = ClassUtil.GetConstructorInfo(ForName(provider_.ParameterType),argTypes);
125   return (IDataParameter) ConstructorUtil.NewInstance(constructor,
126   new object[] { name, dataType, size });
127   }
128  
129 0 public System.Data.IDataParameter GetParameter(string name, System.Data.DbType dataType, int size, string srcColumn)
130   {
131   IDataParameter param = this.GetParameter(name, dataType, size);
132   param.SourceColumn = srcColumn;
133   return param;
134   }
135  
136 0 public IDataAdapter GetDataAdapter()
137   {
138   return (IDataAdapter) ClassUtil.NewInstance(ForName(provider_.DataAdapterType));
139   }
140  
141 10 public IDataAdapter GetDataAdapter(IDbCommand selectCommand)
142   {
143 10 Type[] argTypes = new Type[] { ForName(provider_.CommandType) };
144 10 ConstructorInfo constructor = ClassUtil.GetConstructorInfo(ForName(provider_.DataAdapterType), argTypes);
145 10 return (IDataAdapter) ConstructorUtil.NewInstance(constructor, new object[] { selectCommand });
146   }
147  
148 0 public IDataAdapter GetDataAdapter(string selectCommandText, string selectConnectionString)
149   {
150   Type[] argTypes = new Type[] { typeof(string), typeof(string) };
151   ConstructorInfo constructor = ClassUtil.GetConstructorInfo(ForName(provider_.DataAdapterType), argTypes);
152   return (IDataAdapter) ConstructorUtil.NewInstance(constructor,
153   new object[] { selectCommandText, selectConnectionString });
154   }
155  
156 0 public IDataAdapter GetDataAdapter(string selectCommandText, IDbConnection selectConnection)
157   {
158   Type[] argTypes = new Type[] { typeof(string), ForName(provider_.ConnectionType) };
159   ConstructorInfo constructor = ClassUtil.GetConstructorInfo(ForName(provider_.DataAdapterType), argTypes);
160   return (IDataAdapter) ConstructorUtil.NewInstance(constructor,
161   new object[] { selectCommandText, selectConnection });
162   }
163  
164 0 public virtual IDbTransaction GetTransaction()
165   {
166   throw new NotSupportedException("GetTransaction");
167   }
168  
169   #endregion
170  
171 82 private static Type ForName(string name)
172   {
173 82 return ClassUtil.ForName(name, AppDomain.CurrentDomain.GetAssemblies());
174   }
175   }
176   }
177