Allow class name only function resolution in mod_mono because some people were too lazy to fully qualify

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9456 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Giagnocavo 2008-09-04 23:28:10 +00:00
parent b95e23441d
commit fb9e85df57
1 changed files with 7 additions and 2 deletions

View File

@ -42,6 +42,8 @@ namespace FreeSWITCH
{
// Stores a list of the loaded function types so we can instantiate them as needed
static readonly Dictionary<string, Type> functions = new Dictionary<string, Type>(StringComparer.InvariantCultureIgnoreCase);
// Only class name. Last in wins.
static readonly Dictionary<string, Type> shortFunctions = new Dictionary<string, Type>(StringComparer.InvariantCultureIgnoreCase);
#region Load/Unload
@ -86,6 +88,7 @@ namespace FreeSWITCH
if (shouldLoad) {
Log.WriteLine(LogLevel.Notice, "Function {0} loaded.", t.FullName);
functions.Add(t.FullName, t);
shortFunctions[t.Name] = t;
}
else {
Log.WriteLine(LogLevel.Notice, "Function {0} requested not to be loaded.", t.FullName);
@ -137,8 +140,10 @@ namespace FreeSWITCH
{
Type t;
if (!functions.TryGetValue(fullName, out t) || !t.IsSubclassOf(typeof(TFunction))) {
Log.WriteLine(LogLevel.Error, "Could not find function {0}.", fullName);
return null;
if (!shortFunctions.TryGetValue(fullName, out t) || !t.IsSubclassOf(typeof(TFunction))) {
Log.WriteLine(LogLevel.Error, "Could not find function {0}.", fullName);
return null;
}
}
return t;
}