提交 e6d513eb authored 作者: Michael Giagnocavo's avatar Michael Giagnocavo

Call entrypoint on scripts so they can perform initialization

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@14399 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 60ff1eb5
...@@ -43,6 +43,7 @@ using System.Reflection.Emit; ...@@ -43,6 +43,7 @@ using System.Reflection.Emit;
namespace FreeSWITCH { namespace FreeSWITCH {
public enum ScriptContextType { public enum ScriptContextType {
None,
App, App,
Api, Api,
ApiBackground, ApiBackground,
...@@ -151,6 +152,11 @@ namespace FreeSWITCH { ...@@ -151,6 +152,11 @@ namespace FreeSWITCH {
} }
bool processAssembly(string fileName, Assembly asm) { bool processAssembly(string fileName, Assembly asm) {
// Call the entrypoint once, to initialize apps that need their main called
var entryPoint = getEntryDelegate(asm.EntryPoint);
try { entryPoint(); } catch { }
// Check for loading
var allTypes = asm.GetExportedTypes(); var allTypes = asm.GetExportedTypes();
if (!RunLoadNotify(allTypes)) return false; if (!RunLoadNotify(allTypes)) return false;
...@@ -159,7 +165,6 @@ namespace FreeSWITCH { ...@@ -159,7 +165,6 @@ namespace FreeSWITCH {
AddAppPlugins(allTypes); AddAppPlugins(allTypes);
// Add the script executors // Add the script executors
var entryPoint = getEntryDelegate(asm.EntryPoint);
var name = Path.GetFileName(fileName); var name = Path.GetFileName(fileName);
var aliases = new List<string> { name }; var aliases = new List<string> { name };
this.ApiExecutors.Add(new ApiPluginExecutor(name, aliases, () => new ScriptApiWrapper(entryPoint))); this.ApiExecutors.Add(new ApiPluginExecutor(name, aliases, () => new ScriptApiWrapper(entryPoint)));
...@@ -181,6 +186,7 @@ namespace FreeSWITCH { ...@@ -181,6 +186,7 @@ namespace FreeSWITCH {
try { try {
entryPoint(); entryPoint();
} finally { } finally {
Script.contextType = ScriptContextType.None;
Script.context = null; Script.context = null;
} }
} }
...@@ -191,6 +197,7 @@ namespace FreeSWITCH { ...@@ -191,6 +197,7 @@ namespace FreeSWITCH {
try { try {
entryPoint(); entryPoint();
} finally { } finally {
Script.contextType = ScriptContextType.None;
Script.context = null; Script.context = null;
} }
} }
...@@ -210,6 +217,7 @@ namespace FreeSWITCH { ...@@ -210,6 +217,7 @@ namespace FreeSWITCH {
try { try {
entryPoint(); entryPoint();
} finally { } finally {
Script.contextType = ScriptContextType.None;
Script.context = null; Script.context = null;
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论