System.Reflection.MethodInfo GetMethodSlow(CSLE.CLS_Content content, bool bStatic, string funcname, IList<Type> types, IList<object> _params)
{
List<object> myparams = new List<object>(_params);
if (slowCache == null)
{
System.Reflection.MethodInfo[] ms = this.type.GetMethods();
slowCache = new Dictionary<string, IList<System.Reflection.MethodInfo>>();
foreach (var m in ms)
{
string name = m.IsStatic ? "s=" + m.Name : m.Name;
if (slowCache.ContainsKey(name) == false)
{
slowCache[name] = new List<System.Reflection.MethodInfo>();
}
slowCache[name].Add(m);
}
}
IList<System.Reflection.MethodInfo> minfo = null;
if (slowCache.TryGetValue(bStatic ? "s=" + funcname : funcname, out minfo) == false)
return null;
foreach (var m in minfo)
{
bool match = true;
var pp = m.GetParameters();
if (pp.Length < types.Count)//参数多出来,不匹配
{
match = false;
continue;
}
for (int i = 0; i < pp.Length; i++)
{
if (i >= types.Count)//参数多出来
{
if (!pp[i].IsOptional)
{
match = false;
break;
}
else
{
myparams.Add(pp[i].DefaultValue);
continue;
}
}
else
{
if (pp[i].ParameterType == types[i]) continue;
try
{
if (types[i] == null && !pp[i].ParameterType.IsValueType)
{
continue;
}
myparams[i] = content.environment.GetType(types[i]).ConvertTo(content, _params[i], pp[i].ParameterType);
if (myparams[i] == null)
{
match = false;
break;
}
}
catch
{
match = false;
break;
}
}
if (match)
break;
}
if (!match)
{
continue;
}
else
{
for (int i = 0; i < myparams.Count; i++)
{
if (i < _params.Count)
{
_params[i] = myparams[i];
}
else
{
_params.Add(myparams[i]);
}
}
return m;
}
}
if (minfo.Count == 1)
return minfo[0];
return null;
}
public virtual CLS_Content.Value MemberCallCache(CLS_Content content, object object_this, IList<CLS_Content.Value> _params, MethodCache cache)