Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to do this in .NET
Message
De
16/04/2005 10:28:03
 
 
À
15/04/2005 14:58:44
Walter Meester
HoogkarspelPays-Bas
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
01004810
Message ID:
01005454
Vues:
35
This message has been marked as the solution to the initial question of the thread.
Walter,

>On top of that it has to call this method to get the filterexpression back.
>Any hints for how this might be done ??<


Sorry that I didn't get back to you yesterday on this question, I was swamped. I thought maybe you would take a cue from my code on using reflection to figure out how to invoke a method, as the code is quite similar. If I can figure it out (never having done it before), I'm sure you could have too. Anyway, I modified my PemStatus() method that I posted last time so that you have an additional parameter indicating whether you're looking for a Property, Event or Method:
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>

~~Bonnie
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform