Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to do this in .NET
Message
De
18/04/2005 04:03:27
Walter Meester
HoogkarspelPays-Bas
 
 
À
16/04/2005 10:28:03
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
01004810
Message ID:
01005689
Vues:
32
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform