@@ -29,10 +29,25 @@ protected void VerifyNotDisposed()
2929
3030 protected abstract object InnerEvaluate ( string expression ) ;
3131
32+ protected virtual object InnerEvaluate ( string expression , string documentName )
33+ {
34+ return InnerEvaluate ( expression ) ;
35+ }
36+
3237 protected abstract T InnerEvaluate < T > ( string expression ) ;
3338
39+ protected virtual T InnerEvaluate < T > ( string expression , string documentName )
40+ {
41+ return InnerEvaluate < T > ( expression ) ;
42+ }
43+
3444 protected abstract void InnerExecute ( string code ) ;
3545
46+ protected virtual void InnerExecute ( string code , string documentName )
47+ {
48+ InnerExecute ( code ) ;
49+ }
50+
3651 protected abstract object InnerCallFunction ( string functionName , params object [ ] args ) ;
3752
3853 protected abstract T InnerCallFunction < T > ( string functionName , params object [ ] args ) ;
@@ -96,6 +111,19 @@ public virtual object Evaluate(string expression)
96111 return InnerEvaluate ( expression ) ;
97112 }
98113
114+ public virtual object Evaluate ( string expression , string documentName )
115+ {
116+ VerifyNotDisposed ( ) ;
117+
118+ if ( string . IsNullOrWhiteSpace ( expression ) )
119+ {
120+ throw new ArgumentException (
121+ string . Format ( Strings . Common_ArgumentIsEmpty , "expression" ) , "expression" ) ;
122+ }
123+
124+ return InnerEvaluate ( expression , documentName ) ;
125+ }
126+
99127 public virtual T Evaluate < T > ( string expression )
100128 {
101129 VerifyNotDisposed ( ) ;
@@ -116,6 +144,26 @@ public virtual T Evaluate<T>(string expression)
116144 return InnerEvaluate < T > ( expression ) ;
117145 }
118146
147+ public virtual T Evaluate < T > ( string expression , string documentName )
148+ {
149+ VerifyNotDisposed ( ) ;
150+
151+ if ( string . IsNullOrWhiteSpace ( expression ) )
152+ {
153+ throw new ArgumentException (
154+ string . Format ( Strings . Common_ArgumentIsEmpty , "expression" ) , "expression" ) ;
155+ }
156+
157+ Type returnValueType = typeof ( T ) ;
158+ if ( ! ValidationHelpers . IsSupportedType ( returnValueType ) )
159+ {
160+ throw new NotSupportedTypeException (
161+ string . Format ( Strings . Runtime_ReturnValueTypeNotSupported , returnValueType . FullName ) ) ;
162+ }
163+
164+ return InnerEvaluate < T > ( expression , documentName ) ;
165+ }
166+
119167 public virtual void Execute ( string code )
120168 {
121169 VerifyNotDisposed ( ) ;
@@ -129,6 +177,19 @@ public virtual void Execute(string code)
129177 InnerExecute ( code ) ;
130178 }
131179
180+ public virtual void Execute ( string code , string documentName )
181+ {
182+ VerifyNotDisposed ( ) ;
183+
184+ if ( string . IsNullOrWhiteSpace ( code ) )
185+ {
186+ throw new ArgumentException (
187+ string . Format ( Strings . Common_ArgumentIsEmpty , "code" ) , "code" ) ;
188+ }
189+
190+ InnerExecute ( code , documentName ) ;
191+ }
192+
132193 public virtual void ExecuteFile ( string path , Encoding encoding = null )
133194 {
134195 VerifyNotDisposed ( ) ;
@@ -140,7 +201,7 @@ public virtual void ExecuteFile(string path, Encoding encoding = null)
140201 }
141202
142203 string code = Utils . GetFileTextContent ( path , encoding ) ;
143- Execute ( code ) ;
204+ Execute ( code , path ) ;
144205 }
145206
146207 public virtual void ExecuteResource ( string resourceName , Type type )
@@ -166,7 +227,7 @@ public virtual void ExecuteResource(string resourceName, Type type)
166227 }
167228
168229 string code = Utils . GetResourceAsString ( resourceName , type ) ;
169- Execute ( code ) ;
230+ Execute ( code , resourceName ) ;
170231 }
171232
172233 public virtual void ExecuteResource ( string resourceName , Assembly assembly )
@@ -192,7 +253,7 @@ public virtual void ExecuteResource(string resourceName, Assembly assembly)
192253 }
193254
194255 string code = Utils . GetResourceAsString ( resourceName , assembly ) ;
195- Execute ( code ) ;
256+ Execute ( code , resourceName ) ;
196257 }
197258
198259 public virtual object CallFunction ( string functionName , params object [ ] args )
0 commit comments