Clover.NET coverage report - Coverage for s2container.net

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

File Stats: LOC: 82   Methods: 4
NCLOC: 60 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
Seasar.Framework.Util\DataSourceUtil.cs 80.0% 88.9% 75.0% 84.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.Data;
21   using Seasar.Extension.ADO;
22   using Seasar.Extension.Tx.Impl;
23   using Seasar.Framework.Exceptions;
24   using Seasar.Framework.Log;
25  
26   namespace Seasar.Framework.Util
27   {
28   public sealed class DataSourceUtil
29   {
30   private static readonly Logger logger = Logger.GetLogger(typeof(DataSourceUtil));
31  
32 0 private DataSourceUtil()
33   {
34   }
35  
36 82 public static IDbConnection GetConnection(IDataSource dataSource)
37   {
38 82 try
39   {
40 82 IDbConnection cn = dataSource.GetConnection();
41 82 if(cn.State != ConnectionState.Open)
42   {
43 47 cn.Open();
44 47 logger.Log("DSSR0007", null);
45   }
46 82 return cn;
47   }
48   catch(Exception ex)
49   {
50 0 throw new SQLRuntimeException(ex);
51   }
52   }
53  
54 37 public static void CloseConnection(IDataSource dataSource, IDbConnection cn)
55   {
56 37 try
57   {
58 37 if(dataSource is TxDataSource)
59   {
60 37 TxDataSource txDataSoure = dataSource as TxDataSource;
61 37 if(txDataSoure.Context.IsInTransaction) return;
62   }
63 2 ConnectionUtil.Close(cn);
64   }
65   catch(Exception ex)
66   {
67 0 throw new SQLRuntimeException(ex);
68   }
69   }
70  
71 40 public static void SetTransaction(IDataSource dataSource, IDbCommand cmd)
72   {
73 40 if(dataSource is TxDataSource)
74   {
75 40 TxDataSource txDataSource = dataSource as TxDataSource;
76 40 if(txDataSource.Context.IsInTransaction)
77 38 cmd.Transaction = txDataSource.Context.Current.Transaction;
78   }
79   }
80   }
81   }
82