Clover.NET coverage report - Coverage for s2container.net

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

File Stats: LOC: 100   Methods: 10
NCLOC: 72 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
Seasar.Framework.Util\ResourceUtil.cs 75.0% 80.0% 70.0% 76.6%
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.IO;
21   using System.Reflection;
22  
23   namespace Seasar.Framework.Util
24   {
25   public sealed class ResourceUtil
26   {
27 0 private ResourceUtil()
28   {
29   }
30  
31 283 public static string GetExtension(string path)
32   {
33 283 int extPos = path.LastIndexOf(".");
34 283 if(extPos >= 0)
35   {
36 282 return path.Substring(extPos + 1);
37   }
38   else
39   {
40 1 return null;
41   }
42   }
43  
44 732 public static string GetResourcePath(string path, string extension)
45   {
46 0 if(extension == null) return path;
47 0 if(path.EndsWith(extension)) return path;
48 732 extension = "." + extension;
49 732 return path.Replace(Path.DirectorySeparatorChar,'.') + extension;
50   }
51  
52 0 public static StreamReader GetResourceAsStreamReader(string path)
53   {
54   return GetResourceAsStreamReader(path,Assembly.GetEntryAssembly());
55   }
56  
57 141 public static StreamReader GetResourceAsStreamReader(string path, string extension)
58   {
59 141 return GetResourceAsStreamReader(GetResourcePath(path, extension), Assembly.GetEntryAssembly());
60   }
61  
62 591 public static StreamReader GetResourceAsStreamReader(string path, string extension, Assembly assembly)
63   {
64 591 return GetResourceAsStreamReader(GetResourcePath(path, extension), assembly);
65   }
66  
67 740 public static StreamReader GetResourceAsStreamReader(string path, Assembly assembly)
68   {
69 740 return new StreamReader(GetResourceAsStream(path, assembly));
70   }
71  
72 889 public static Stream GetResourceAsStream(string path, Assembly assembly)
73   {
74 889 if(assembly == null) throw new ResourceNotFoundRuntimeException(path);
75  
76 748 Stream stream = GetResourceNoException(path, assembly);
77 748 if(stream != null)
78   {
79 297 return stream;
80   }
81   else
82   {
83 451 throw new ResourceNotFoundRuntimeException(path);
84   }
85   }
86  
87 797 public static Stream GetResourceNoException(string path, Assembly asm)
88   {
89 0 if(asm == null) return null;
90 797 Stream stream = asm.GetManifestResourceStream(path);
91 797 return stream;
92   }
93  
94 0 public static bool IsExist(string path, Assembly asm)
95   {
96   return GetResourceNoException(path, asm) != null;
97   }
98   }
99   }
100