Clover.NET coverage report - Coverage for s2container.net

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

File Stats: LOC: 96   Methods: 4
NCLOC: 53 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
Seasar.Framework.Util\JScriptUtil.cs - 90.9% 75.0% 86.7%
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 Microsoft.JScript;
20   using System;
21   using System.Collections;
22   using System.Reflection;
23   using System.CodeDom.Compiler;
24   using Seasar.Framework.Exceptions;
25  
26   namespace Seasar.Framework.Util
27   {
28   /// <summary>
29   /// CodeDomでJScript.NETを扱えるようにします。
30   /// </summary>
31   public sealed class JScriptUtil
32   {
33   private static CodeDomProvider provider_ = new JScriptCodeProvider();
34   private static Type evaluateType_;
35  
36   private const string EVAL_SOURCE = @"
37   package Seasar.Framework.Util.JScript
38   {
39   class Evaluator
40   {
41   public static function Eval(expr : String,unsafe : boolean,
42   self : Object,out : Object,err : Object, container : Object) : Object
43   {
44   if(unsafe)
45   {
46   return eval(expr,'unsafe');
47   }
48   else
49   {
50   return eval(expr);
51   }
52   }
53   }
54   }";
55  
56 0 private JScriptUtil()
57   {
58   }
59  
60 1 static JScriptUtil()
61   {
62 1 CompilerParameters parameters = new CompilerParameters();
63 1 parameters.GenerateInMemory = true;
64 1 CompilerResults results = provider_.CompileAssemblyFromSource(parameters, EVAL_SOURCE);
65 1 Assembly assembly = results.CompiledAssembly;
66 1 evaluateType_ = assembly.GetType("Seasar.Framework.Util.JScript.Evaluator");
67   }
68  
69 7 public static object Evaluate(string exp,Hashtable ctx, object root)
70   {
71 7 try
72   {
73 7 return evaluateType_.InvokeMember("Eval",BindingFlags.InvokeMethod,
74   null,null,new object[] {exp,true,ctx["self"],ctx["out"],ctx["err"],root});
75   }
76   catch(Exception ex)
77   {
78 0 throw new JScriptEvaluateRuntimeException(exp,ex);
79   }
80   }
81  
82 305 public static object Evaluate(string exp, object root)
83   {
84 305 try
85   {
86 305 return evaluateType_.InvokeMember("Eval",BindingFlags.InvokeMethod,
87   null,null,new object[] {exp,true,null,null,null,root});
88   }
89   catch(Exception ex)
90   {
91 2 throw new JScriptEvaluateRuntimeException(exp,ex);
92   }
93   }
94   }
95   }
96