What if you use composition? Create a new class to contain all your
shared functionality, then in each control class create an instance
variable of that type. That way you don't have to implement the code in
multiple places. Like:

public class MyCommonFunctionality
  public sub Method1
  end sub
...
end class

Public Class MyLabel
  Inherits System.Web.UI.WebControls.Label
  private _common as new MyCommonFunctionality
...
  _common.Method1
...
end class
---scott

>>> [EMAIL PROTECTED] 2/15/2007 7:33:46 PM >>>
Hey all,

I am trying to reuse a bunch of Class members, properties, and
functions
that are shared across multiple classes.  Each of these classes
already
inherit form a web control so I can not create a base class supporting
the
function since .Net does not support multiple inheritance.  Right now
each
Inherited class has a complete copy of this code that makes it hard to
make
changes to it.

So invision...
MyControl1--\                   /---BaseControl1
MyControl2--->Common Code Class<----BaseControl2
MyControl3--/                   \---BaseControl3

What I really need is multiple inheritance...

Public Class MyLabel
        Inherits System.Web.UI.WebControls.Label)
        Inherits MyCommonStuff

End Class

Since so many of these are shared properties and members using basic
interfaces would not really save that much code space.  What I was
trying to
do is mix in generics and do something along these lines...

Public Class MyBaseControl(Of t)
        Inherits t

        Class members...
        Functions...
        Properties...
End Class

Public Class MyLabel
    Inherits MyBaseControl(Of System.Web.UI.WebControls.Label)

End Class

Public Class MyTextbox
    Inherits MyBaseControl(Of System.Web.UI.WebControls.Textbox)

End Class

So what I need is to somehow make my intermediate class inherit the
base
control of my choice at runtime based on the type passed through the
generic.  Is anything like this possible?  I have not had any luck so
far.

Thanks for any help,

Jon

===================================
This list is hosted by DevelopMentor*  http://www.develop.com

View archives and manage your subscription(s) at
http://discuss.develop.com

-----------------------------------------------------
This electronic mail transmission contains information from P&H
Mining Equipment which is confidential, and is intended only for
the use of the proper Addressee.  If you are not the intended recipient,
please notify us immediately at the return address on this transmission,
or by telephone at (414) 671-4400, and delete this message and any
attachments from your system.  Unauthorized use, copying, disclosing,
distributing, or taking any action in reliance on the contents of this
transmission is strictly prohibited and may be unlawful.  PHUS
-----------------------------------------------------
-Privacy-

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to