Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to do this in .NET
Message
From
18/04/2005 04:03:27
Walter Meester
HoogkarspelNetherlands
 
 
To
16/04/2005 10:28:03
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01004810
Message ID:
01005689
Views:
34
Hi bonnie,

>
>public bool PemStatus(object o, string name, string PEM)
>{
>	switch (PEM.ToUpper())
>	{
>		case "P" :
>			System.Reflection.PropertyInfo pi = o.GetType().GetProperty(name);
>			if (pi == null)
>				return false;
>			else
>				return true;
>		case "E" :
>			System.Reflection.EventInfo ei = o.GetType().GetEvent(name);
>			if (ei == null)
>				return false;
>			else
>				return true;
>		case "M" :
>			System.Reflection.MethodInfo mi = o.GetType().GetMethod(name);
>			if (mi == null)
>				return false;
>			else
>				return true;
>		default :
>			return false;
>	}
>}
>
>And the code to call it:
>
>if (this.PemStatus(oObject, "SetFilter", "M"))
>{
>	// You didn't say if this method call required any parameters, but if it does,
>	// they need to be passed in as an array of objects.
>	object[] parms = new object[1];
>	parms[0] = "MyParm";
>	MyFilter = (string)oObject.GetType().GetMethod("SetFilter").Invoke(oObject, parms);
>}
>
>I still like interfaces better!!! <g>

Well though the above does not look real pretty, from an architectual view I like this better. Writing such functionality now is independed from the implementation of the classes, hence my favour the above.

Anyways, thanks for the solution above.

Walter
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform