So what i am trying to do is ;
-
I am getting a string input from user.
-
I am searching the system if project contains a function with the same name of user input.
-
If i find a function with the same name of input i am trying to execute / invoke it.
-
Usually this function is placed into another class , so i tried to create instance of class using Activators but invoke function still fails.
-
Invoke function gives me error:
Can not invoke method : (methodName) method could not be called!
Here is the code that i am currently working on:
public void Execute()
{
// If we are only looking for function inputs.
if ( !m_canReadCls )
{
// If there is already a class linked into Developer Console.
if ( s_linkedType != null )
{
MethodInfo[] tmp = ReflectionExtensions.GetFunctions( s_linkedType );
// Using linear search algorithm for executing functions.
// Need to optimize it !
if ( tmp != null )
{
string funcName = m_uProps.m_inptField.text;
int i;
for ( i = 0 ; i < tmp.Length ; i++ )
{
if ( tmp[ i ].Name == funcName )
{
var instance = Activator.CreateInstance( s_linkedType );
MethodInfo m = instance.GetType().GetMethod( funcName );
Invoke( m.Name , 0.0f );
Reset();
}
}
}
}
}
}
Any help is great, thanks :-)
Aucun commentaire:
Enregistrer un commentaire