creating a base business class - converting from c#

creating a base business class - converting from c#

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


matt tag posted on Wednesday, December 16, 2009

I pulled the definition below from MyCsla.  Can someone help me translate it into VB.NET?

I'm afraid I'm turning into a "get off my lawn" type developer - my experience in generics is truly lacking.

thank you.


  public abstract class BusinessCore<T>
    : MyCsla.BusinessBase<T>
    where T : BusinessCore<T>


RockfordLhotka replied on Wednesday, December 16, 2009

Public MustInherit Class BusinessCore(Of T As BusinessCore(Of T))
  Inherits MyCsla.BusinessBase(Of T)

Oh, and now that I've helped you, get off my lawn!! And stop playing that loud music!! And slow down when driving down my street, somebody's gonna get hurt! :)

JoeFallon1 replied on Thursday, December 17, 2009

Give a man a fish...

http://www.developerfusion.com/tools/convert/csharp-to-vb/

Joe

 

matt tag replied on Thursday, March 11, 2010

more trouble with this.   I have created a base class named ListCore as follows:

 

Public MustInherit Class ListCore(Of T As BusinessBase(Of T))
    Inherits Csla.BusinessBase(Of T)

 

And Inherited classes declare like so:

Public Class Preflist
    Inherits ListCore(Of Preflist)

Public Class Blackboard
    Inherits ListCore(Of Blackboard)

 

That's working ok.  But now I want to create a variable on a form for editing (I will be editing either a Preflist or Blackboard above, but only properties in the base ListCore class.  I declare the variable on the form this way

private fLst as ListCore

and I get the syntax error "too few type arguments to DV.Lib.ListCore(of T)".   How do I declare this variable?

 

 

 

 

RockfordLhotka replied on Thursday, March 11, 2010

Dan is absolutely correct.

You need to create an interface for your child objects, and one list that contains either (or both) types of child object based on that interface.

The trick to making this work is to make your child object interface inherit from IEditableBusinessObject, because that's the constraint on the C type in BusinessListBase(Of T, C).

Copyright (c) Marimer LLC