Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 providing function name after execution

Author  Topic 

olay80
Yak Posting Veteran

62 Posts

Posted - 2005-06-14 : 04:26:46
hey guys,
i need to provide the function name through a variable after execution any suggestions??
ex:
class.functionName(...);
i need to do the following:
class."+name+"(...) and the "name" will hold the "functionName" value.


thanx,
Oliver

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-06-14 : 04:39:55
look up Type.InvokeMember method.

you can also do this:

string className = "yourClassName";
string customProperty = "yourPropertyName";
string customMethod = "yourMethodName";

object cClassProperty = cAssembly.CreateInstance(className);

PropertyInfo pi = cClassProperty.GetType().GetProperty(customProperty);
if (pi != null) cClassProperty = pi.GetValue(cClassProperty, null);

MethodInfo mi = cClassProperty.GetType().GetMethod(customMethod);
if (mi != null) cClassProperty = mi.Invoke(cClassProperty, null);



Go with the flow & have fun! Else fight the flow
Go to Top of Page

olay80
Yak Posting Veteran

62 Posts

Posted - 2005-06-15 : 02:57:34
thanx alot, i thought that

cAssembly.CreateInstance(className);

should be to instanciate object from a registered dll.

Oliver
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-06-15 : 03:47:05
sorry, forgot this line:

Assembly cAssembly = Assembly.LoadFrom(yourDllName+".dll");


Go with the flow & have fun! Else fight the flow
Go to Top of Page
   

- Advertisement -