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

>>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. <

Well, I guess we'll have to agree to disagree, although I still think you're missing the point of an interface. There is no additional functionality implemented in the classes. You already want to have a SetFilter() method or a SetFocusAtAdd property in your classes, so you're not adding any functionality at all to those classes that need that method or that property. All you're doing is setting up the class definition to implement one or more interfaces.

As an example, you could have an ISetFocus interface (that stipulates that the class contain a SetFocusAtAdd property), and a IFilter interface (that stipulates that the class contains a SetFilter() method). You'd only implement these interfaces on the classes that you need to.

~~Bonnie




>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
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform