Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Multiple Inheritance Dilemma
Message
De
09/09/2005 14:17:13
 
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Versions des environnements
Environment:
C# 1.1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01047884
Message ID:
01048221
Vues:
16
Put the code or functionality in a entirely separate class. Then at runtime or whatever you can assign that class to a property.

FormObject.FunctionalityClass.GetBasePath()

You can define an interface that has a GetBasePath() method and from that method call the configured class.

So your FormObject may have a method called GetBasePath() and that method calls the GetBasePath() method on your "FunctionalityClass".

That way the code is only in the FunctionalityClass and not in both base classes.

I don't know enough .Net code to work up the classes quickly but heres the idea in semi fox code.
DEFINE CLASS BasePath as CUSTOM
FUNCTION GetBasePath()
  *!* Code to get the base path
ENDFUNC
ENDDEFINE

DEFINE CLASS YourFormObject AS KevinsFormObject
oBasePath = NULL
FUNCTION INIT
  This.oBasePath = CREATEOBJECT([BasePath])
ENDFUNC
FUNCTION GetBasePath()
  RETURN This.oBasePath.GetBasePath()
ENDFUNC
ENDDEFINE

*!* Same thing for both classes
DEFINE CLASS YourLoginFormObject AS KevinsLoginFormObject
oBasePath = NULL
FUNCTION INIT
  This.oBasePath = CREATEOBJECT([BasePath])
ENDFUNC
FUNCTION GetBasePath()
  RETURN This.oBasePath.GetBasePath()
ENDFUNC
ENDDEFINE
You can then (in .NET) define an HasGetBase (or whatever) interface that has the GetBasePath() method and assign it to both form objects. That way you can cast to your HasGetBase interface for either object.

Aloha,

James


>Yes, I do already have the property defined in both JdaBusinessWebPage and JdaBaseUserLogin classes. I also have all of the logic to build the base path in the OnLoad of both of those classes. Having that exact same code replicated in multiple classes stinks too, but I have some pages based on Kevin's mmBaseUserLogin class and some pages based on his mmBusinessWebPage on my site, but they all need this property. I don't see any way around replicating that code. :(
>
>I do understand what you were saying about defining the Interface so I can cast to. I will probably go with that solution for now. Thanks!
>
>Matt
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform