64 lines
1.8 KiB
C#
64 lines
1.8 KiB
C#
using System;
|
|
using System.Runtime.Remoting;
|
|
using AspClassic.Scripting.Runtime;
|
|
using AspClassic.Scripting.Utils;
|
|
|
|
namespace AspClassic.Scripting.Hosting.Providers;
|
|
|
|
public static class HostingHelpers
|
|
{
|
|
public static ScriptDomainManager GetDomainManager(ScriptRuntime runtime)
|
|
{
|
|
ContractUtils.RequiresNotNull(runtime, "runtime");
|
|
return runtime.Manager;
|
|
}
|
|
|
|
public static LanguageContext GetLanguageContext(ScriptEngine engine)
|
|
{
|
|
ContractUtils.RequiresNotNull(engine, "engine");
|
|
return engine.LanguageContext;
|
|
}
|
|
|
|
public static SourceUnit GetSourceUnit(ScriptSource scriptSource)
|
|
{
|
|
ContractUtils.RequiresNotNull(scriptSource, "scriptSource");
|
|
return scriptSource.SourceUnit;
|
|
}
|
|
|
|
public static ScriptCode GetScriptCode(CompiledCode compiledCode)
|
|
{
|
|
ContractUtils.RequiresNotNull(compiledCode, "compiledCode");
|
|
return compiledCode.ScriptCode;
|
|
}
|
|
|
|
public static SharedIO GetSharedIO(ScriptIO io)
|
|
{
|
|
ContractUtils.RequiresNotNull(io, "io");
|
|
return io.SharedIO;
|
|
}
|
|
|
|
public static Scope GetScope(ScriptScope scriptScope)
|
|
{
|
|
ContractUtils.RequiresNotNull(scriptScope, "scriptScope");
|
|
return scriptScope.Scope;
|
|
}
|
|
|
|
public static ScriptScope CreateScriptScope(ScriptEngine engine, Scope scope)
|
|
{
|
|
ContractUtils.RequiresNotNull(engine, "engine");
|
|
ContractUtils.RequiresNotNull(scope, "scope");
|
|
ContractUtils.Requires(!RemotingServices.IsTransparentProxy(engine), "engine", "The engine cannot be a transparent proxy");
|
|
return new ScriptScope(engine, scope);
|
|
}
|
|
|
|
[Obsolete("You should implement a service via LanguageContext and call ScriptEngine.GetService")]
|
|
public static TRet CallEngine<T, TRet>(ScriptEngine engine, Func<LanguageContext, T, TRet> f, T arg)
|
|
{
|
|
return engine.Call(f, arg);
|
|
}
|
|
|
|
public static DocumentationOperations CreateDocumentationOperations(DocumentationProvider provider)
|
|
{
|
|
return new DocumentationOperations(provider);
|
|
}
|
|
}
|