mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-21 11:17:28 +08:00
Correcting Orchard.Scripting project file and namespaces
--HG-- branch : dev
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using Microsoft.Scripting.Hosting;
|
||||
|
||||
namespace Orchard.Scripting.Services {
|
||||
public class ScriptingManager : IScriptingManager {
|
||||
private readonly IScriptingRuntime _scriptingRuntime;
|
||||
private Lazy<ScriptScope> _scope;
|
||||
private Lazy<ObjectOperations> _operations;
|
||||
|
||||
public ScriptingManager(IScriptingRuntime scriptingRuntime) {
|
||||
_scriptingRuntime = scriptingRuntime;
|
||||
_scope = new Lazy<ScriptScope>(()=>_scriptingRuntime.CreateScope());
|
||||
_operations = new Lazy<ObjectOperations>(()=>_scope.Value.Engine.CreateOperations());
|
||||
}
|
||||
|
||||
public dynamic GetVariable(string name) {
|
||||
return _scope.Value.GetVariable(name);
|
||||
}
|
||||
|
||||
public void SetVariable(string name, object value) {
|
||||
_scope.Value.SetVariable(name, value);
|
||||
}
|
||||
|
||||
public dynamic ExecuteExpression(string expression) {
|
||||
return _scriptingRuntime.ExecuteExpression(expression, _scope.Value);
|
||||
}
|
||||
|
||||
public dynamic ExecuteOperation(Func<ObjectOperations, object> invoke) {
|
||||
return invoke(_operations.Value);
|
||||
}
|
||||
|
||||
public void ExecuteFile(string fileName) {
|
||||
_scriptingRuntime.ExecuteFile(fileName, _scope.Value);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user