Support resolving methods with ref/out parameters
This commit is contained in:
@@ -11,8 +11,15 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
public static Type GetType(string typeName)
|
public static Type GetType(string typeName)
|
||||||
{
|
{
|
||||||
|
var byRef = false;
|
||||||
|
if (typeName.StartsWith("out ") || typeName.StartsWith("ref "))
|
||||||
|
{
|
||||||
|
typeName = typeName.Remove(0, 4);
|
||||||
|
byRef = true;
|
||||||
|
}
|
||||||
|
|
||||||
var type = Type.GetType(typeName);
|
var type = Type.GetType(typeName);
|
||||||
if (type != null) return type;
|
if (type != null) return byRef ? type.MakeByRefType() : type;
|
||||||
foreach (var a in AppDomain.CurrentDomain.GetAssemblies())
|
foreach (var a in AppDomain.CurrentDomain.GetAssemblies())
|
||||||
{
|
{
|
||||||
if (CsScriptBase.LoadedAssemblyName.Contains(a.GetName().Name))
|
if (CsScriptBase.LoadedAssemblyName.Contains(a.GetName().Name))
|
||||||
@@ -24,7 +31,7 @@ namespace Barotrauma
|
|||||||
type = a.GetType(typeName);
|
type = a.GetType(typeName);
|
||||||
if (type != null)
|
if (type != null)
|
||||||
{
|
{
|
||||||
return type;
|
return byRef ? type.MakeByRefType() : type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user