本文整理汇总了C#中System.Script.FindType方法的典型用法代码示例。如果您正苦于以下问题:C# Script.FindType方法的具体用法?C# Script.FindType怎么用?C# Script.FindType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Script
的用法示例。
在下文中一共展示了Script.FindType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public override object Execute(Script script, Scope scope, Token previousToken, object unknown)
{
if (unknown != null)
{
// TODO: Write a better message for this...
throw new Exception("An object cannot be passed to a 'new' object!");
}
return Invoke(script, scope, null, script.FindType(_name), null, _arguments, _generics);
}
示例2: Invoke
/// <summary>
/// Invokes a method on type.
/// </summary>
/// <param name="script"></param>
/// <param name="scope"></param>
/// <param name="obj">The object that the method before returned, this can be null for static methods.</param>
/// <param name="objectType">The type of object.</param>
/// <param name="methodName">The method we want to call, if null, we are assuming that we want to call the constructor for this type.</param>
/// <param name="arguments">The arguments for the method.</param>
/// <param name="generics">If generic, the types we are passing to it.</param>
/// <param name="locals">Local variables.</param>
/// <returns>The result of the method, or Slimterpreter.Void if no return type.</returns>
protected object Invoke(Script script, Scope scope, object obj, Type objectType, string methodName, List<List<Token>> arguments, List<string> generics)
{
if (generics.Count != 0)
{
var genericTypes = new Type[generics.Count];
for (int i = 0; i < generics.Count; i++)
{
Type type = script.FindType(generics[i]);
if (type == null)
{
throw new InvalidCastException("Cannot cast to type " + generics[i]);
}
genericTypes[i] = type;
}
objectType = objectType.MakeGenericType(genericTypes);
}
// Solve the parameters.
var argumentTypes = new Type[arguments.Count];
var argumentValues = new object[arguments.Count];
for (int i = 0; i < arguments.Count; i++)
{
object res = null;
// We need to get to the end of the list of Calls...
for (int j = 0; j < arguments[i].Count; j++)
{
if (j + 1 < arguments[i].Count)
{
res = arguments[i][j].Execute(script, null, null, res);
}
else if (j + 1 == arguments[i].Count)
{
argumentValues[i] = arguments[i][j].Execute(script, scope, null, res);
if (argumentValues[i] == null)
{
argumentTypes[i] = typeof (object);
}
else
{
argumentTypes[i] = argumentValues[i].GetType();
}
}
}
}
if (methodName == null)
{
return ConstructorInvoke(objectType, argumentTypes, argumentValues);
}
else
{
return MethodInvoke(obj, methodName, objectType, argumentTypes, argumentValues);
}
}
示例3: Execute
public override object Execute(Script script, Scope scope, Token previousToken, object unknown)
{
return script.FindType(_id);
}