Help - How to I pass and get a reference to ReadOnlyBase(Of objectInfo)

Help - How to I pass and get a reference to ReadOnlyBase(Of objectInfo)

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


andrewrajcoomar posted on Wednesday, January 21, 2009

Hello,

I'm trying to get a reference to objectInfo where objectInfo inherits from ReadOnlyBase. What I want to do is in my form, pass objectInfo to a method in another class that sets a filter.

I can successfully do this for objectReadOnlyList, where I have a property of type Csla.Core.IReadOnlyCollection, but I can't seem to use a property of type Csla.Core.IReadOnlyObject because:

FilteredBindingList(Of _objectInfo)(_objectReadOnlyList) complains that _objectInfo "Type _objectInfo is not defined"

Really would appreciate some help with this.

Thanks,

Andrew

ajj3085 replied on Thursday, January 22, 2009

Well, is there really a type (class) named _objectInfo?  It looks like an instance reference to me. 

andrewrajcoomar replied on Thursday, January 22, 2009

Sorry, code reference is mis-leading. The _objectInfo is a property of type (object class) in my form. What I am trying to do is abstract a common method for filtering in my baseform, from which my forms are derived. I am expecting the inherited form to be able to set the property in the baseform and then the baseform execute the filter method - for any form.

Thanks,

Andrew

ajj3085 replied on Thursday, January 22, 2009

Sorry.. is _objectInfo a propererty of a certain type, or is it's type actually System.Type.  It needs to be a System.Type.  And it can't be a variable, it must be resolvable at compile time.

andrewrajcoomar replied on Thursday, January 22, 2009

Thanks! This is what I was attempting:

What I was trying to do was create a common method like this in my baseclass:

Me.BOBindingSource.DataSource = New SortedBindingList(Of _ReadOnlyInfo)(_ReadOnlyList). I was hoping in my baseclass to have two properties for _ReadOnlyInfo and _ReadOnlyList and then set these from the calling form.

Part of this works. This is what I have in my baseform:

Private WithEvents _ReadOnlyList As Core.IReadOnlyCollection

Protected Property ReadOnlyList() As Csla.Core.IReadOnlyCollection

Get

Return _ReadOnlyList

End Get

Set(ByVal value As Csla.Core.IReadOnlyCollection)

_ReadOnlyList = value

End Set

End Property

 

Private WithEvents _ReadOnlyInfo As Core.IReadOnlyObject

Public Property ReadOnlyInfo() As Csla.Core.IReadOnlyObject

Get

Return _ReadOnlyInfo

End Get

Set(ByVal value As Csla.Core.IReadOnlyObject)

_ReadOnlyInfo = value

End Set

End Property

 

Private WithEvents _BindingSource As BindingSource

Protected Property BindingSource() As BindingSource

Get

Return _BindingSource

End Get

Set(ByVal value As BindingSource)

baseBindingNavigator.BindingSource = value

_BindingSource = value

...

End If

End Set

End Property

and then in my form, I have:

Private WithEvents _ChartFieldInfo As ChartFieldInfo

Private ReadOnly Property ChartFieldInfo() As ChartFieldInfo

Get

Return _ChartFieldInfo

End Get

End Property

Private WithEvents _ChartFieldList As ChartFieldList

Public ReadOnly Property ChartFieldList() As ChartFieldList

Get

Return _ChartFieldList

End Get

End Property

_ChartFieldList = ChartFieldList.GetChartFieldList()

Me.ChartFieldListBindingSource.DataSource = New SortedBindingList(Of ChartFieldInfo)(_ChartFieldList)

MyBase.BindingSource = Me.ChartFieldListBindingSource

MyBase.ReadOnlyList = _ChartFieldList

MyBase.ReadOnlyInfo = ChartFieldInfo

In the  common method in my baseclass, I'd like to do something lik:

Me.BindingSource.DataSource = New SortedBindingList(Of _ReadOnlyInfo)(_ReadOnlyList)

Note from above, (code in red), I cannot pass _BOInfo (which I like to have as a reference to ChartFieldInfo) as a parm, as the object cannot be resolved.

 

Is something like this possible?

Thanks,

Andrew

 

 

ajj3085 replied on Thursday, January 22, 2009

I think what you want is possible, but you'll need to  use reflection to create the generic SortedBindingList type appropriately.

andrewrajcoomar replied on Thursday, January 22, 2009

Tried that - seems that the parm can't be a reference, of any type. VS complains that "Type 'xxx' is not defined."

ajj3085 replied on Thursday, January 22, 2009

What's the reflection code you tried?

Copyright (c) Marimer LLC