Hi!
Trying to create our own base classes for the 7 main ones.
1] BusinessBase<T>
[Serializable()]
public abstract class MyNewBusinessBase<T> : BusinessBase<T> where T : MyNewBusinessBase<T>
2] BusinessListBase<T,C>
Having trouble with this one!!!
3] CommandBase
?
4] ReadOnlyBase<T>
Similar to 1] ?
5] ReadOnlyListBase<T,C>
?
6] NameValueListBase<K,V>
?
7] EditableRootListBase<T>
Similar to 1] ?
Thanks
Sarosh
Hi Sarosh,
I just did this yesterday or the day before. This is what I have - not really sure if it's correct or not, but it compiles :) I've only used my BusinessBase so far.
2)
using
System;using
System.Collections.Generic;using
System.Text;using
Csla;namespace
Buoy.BusinessObjects203{
[
Serializable] public abstract class BuoyBusinessListBase<T, C> : BusinessListBase<T, C> where T : BuoyBusinessListBase<T, C> where C : Csla.Core.IEditableBusinessObject{
}
}
3)
using
System;using
System.Collections.Generic;using
System.Text;using
Csla;namespace
Buoy.BusinessObjects203{
public abstract class BuoyCommandBase : CommandBase{
}
}
4) Yes
5)
using
System;using
System.Collections.Generic;using
System.Text;using
Csla;namespace
Buoy.BusinessObjects203{
public abstract class BuoyReadOnlyListBase<T, C> : ReadOnlyListBase<T, C> where T : BuoyReadOnlyListBase<T, C>{
}
}
6)
using
System;using
System.Collections.Generic;using
System.Text;using
Csla;namespace
Buoy.BusinessObjects203{
public abstract class BuoyNameValueListBase<K, V> : NameValueListBase<K, V>{
}
}
7) I'm not using 2.1 yet.
Regards,
Mike
Hi!
That's exactly what I was looking for.
Thanks a lot!
Sarosh
Hi!
Thanks for the info. but what about EditableRootListBase
Sarosh
Hi!
I got it for EditableRootListBase<T> as well.
Thanks.
Sarosh
The VB code version of your code is:
<Serializable()> _
Public MustInherit Class MyBusinessListBase(Of T As MyBusinessListBase(Of T, C), C As Core.IEditableBusinessObject)
Inherits BusinessListBase(Of T, C)
End Class
============================================================
Is there anything wrong with this code though:
<Serializable()> _
Public MustInherit Class MyBusinessListBase(Of C As Core.BusinessBase)Inherits BusinessListBase(Of MyBusinessListBase(Of C), C)
End Class
My actual BO lists then can use code like this:
<Serializable()> _
Public Class SomeList Inherits MyBusinessListBase(Of SomeChildBO)
Joe
Rocky,
Can you please comment on the "correct" way to derive from BusinessListBase if you plan to have a layer between CSLA and your own BOs?
I showed 2 alternatives above and was planning on usng the simpler one for my custom layer and then deriving all my lists from it. Will I be losing any functionality? Is this a mistake? Shjould I use the more complex form? If so, what does it gain me in my lists?
Joe
Rocky,
Thanks. I will use the more complex syntax so I don't accidentally lose functionality.
I *do* want to be as compatible as possible.
Joe
I updated my BusinessListBase class to code like this:
=========================================================
<Serializable()> _
Public MustInherit Class MyBusinessListBase(Of T As MyBusinessListBase(Of T, C), C As Core.IEditableBusinessObject) Inherits BusinessListBase(Of T, C)=========================================================
I also have a BusinessBase class like this:
<Serializable()> _
Public MustInherit Class MyBusinessBase(Of T As MyBusinessBase(Of T)) Inherits BusinessBase(Of T)Inside this base class I declare 2 variables.
The first is simple:
Private Shared BIZ_TYPE As Type = GetType(MyBusinessBase(Of T))The 2nd used to be simple but now I can't get it to compile.
It used to be like this:
Private
Shared COLL_TYPE As Type = GetType(MyBusinessListBase(Of Core.IEditableBusinessObject))=========================================================
But now I can't figure out how to re-write the 2nd variable using the base classes above.
Every combination fails to compile.
Any advice?
=========================================================
Joe
Private Shared COLL_TYPE As Type = _
GetType(MyBusinessListBase( _
Of MyBusinessListBase(Of Core.IEditableBusinessObject), Core.IEditableBusinessObject))
Rocky,
That won't compile:
Private Shared COLL_TYPE As Type = GetType(MyBusinessListBase(Of MyBusinessListBase(Of Core.IEditableBusinessObject), Core.IEditableBusinessObject))
It gives the message:
"Too few type arguments to MyBusinessListBase(Of T,C)".
============================================================
This is how my BusinessListBase class is declared now:
<Serializable()> _
============================================================
I can't seem to find a syntax that will compile for T.
I am open to other attempts to fix this.
Update: Omit the T and C parameters (but leave the comma.) Then GetType works.
Private Shared COLL_TYPE As Type = GetType(PNIBusinessListBase(Of ,))===========================================================
I am planning to use this COLL_Type variable in code like this:
Dim coll As PNIBusinessListBase(Of Core.BusinessBase)But none of the lines above will compile now either. Is it incorrect to use generics this way? I am simply trying to get a list of all the broken rules from a given BO which contains other BOs. This code is supposed to loop over all the contained BOs and fetch their broken rules too. This is the method called ALLRules from 1.x which was contributed to the community. Has anyone else used it and re-writen it for 2.0?
Joe
Hi!
This is what I am using.
///
[
Serializable()] public abstract class MyBusinessListBase<T, C> : BusinessListBase<T, C>, IMyEditableBusinessObject where T : MyBusinessListBase<T, C> where C : Csla.Core.IEditableBusinessObject///
Sarosh
Is there anything wrong with:
[Serializable()]
public abstract class MyBusinessBase<T> : Csla.BusinessBase<T>
where T : MyBusinessBase<T>
[Serializable()]
public abstract class MyBusinessListBase<T, C> : Csla.BusinessListBase<T, C>
where T : MyBusinessListBase<T, C>
where C : MyBusinessBase<C>
It compiles and seemes to work fine.
"Is there anything wrong with"
Nope.
Those are correct for C#.
For VB use:
<Serializable()> _
Public MustInherit Class MyBusinessBase(Of T As MyBusinessBase(Of T))
Inherits BusinessBase(Of T)
<Serializable()> _
Public MustInherit Class MyBusinessListBase(Of T As MyBusinessListBase(Of T, C), C As MyBusinessBase)
Inherits BusinessListBase(Of T, C)
Joe
Copyright (c) Marimer LLC