Extending BusinessBase<T> in c#

Extending BusinessBase<T> in c#

Old forum URL: forums.lhotka.net/forums/t/919.aspx


rkelley posted on Wednesday, August 16, 2006

I am trying to extend BusinessBase in a similar fashion to what Petar did with ActiveObjects. I have searched all over to no avail so hopefully someone can help me out. I had a good start on this, I though, however his code is in VB and mine C#

This is what his constructor looks like in VB

Public MustInherit Class ActiveBusinessBase(Of T As BusinessBase(Of T))
  Inherits BusinessBase(Of T)
  Implements IActiveBusinessBase
  Implements ISafeSubscriber

This is what my constructor Looks like:

public abstract class SCBusinessBase : Csla.Core.BusinessBase where T : SCBusinessBase, ISubscriber

With this constructor I get the following error on compilation in my derived class:
"The type MyDerivedClass must be convertible to Observer.ISubscriber in order to use it as a parameter T in the generic type or method SCBusinessBase.

So I make MyDerivedClass implement the same interface (ISubscriber). Then I get errors such as:

"Cannot Convert from SCBusinessBase to Observer.ISubscriber"

I have also tried this:

public abstractclass SCBusinessBase : BusinessBase where T: SCBusinessBase

And several other possibilities. So my question is, how can I extend BusinessBase with my own base class and not have to recode what is already in BusinssBase in the framework?

Brian Criswell replied on Wednesday, August 16, 2006

T (or whatever you name your type parameters) are defined in class definitions or static member definitions.

public abstract class SCBusinessBase<T> : Csla.BusinessBase<T>, ISubscriber
    where T : SCBusinessBase<T>
{
}

rkelley replied on Wednesday, August 16, 2006

Brian,

Thanks for the help it is working now, I just had things out of order.

Thanks,

Ryan

Copyright (c) Marimer LLC