Updated ObjectListView available

Updated ObjectListView available

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


Brian Criswell posted on Thursday, December 21, 2006

I have published a new version of the ObjectListView to the CSLAcontrib site.

New features/fixes:

JoeFallon1 replied on Friday, December 22, 2006

Brian,

Thanks for posting this.

I just ran into a problem with detecting the underlying object type for a Csla2 Read Only Collection and was looking to drop you a line about it. If you are open to private emails then please send me one at

jfallon at purchasingnet dot com  (relace the words at and dot with the appropriate symbols.)

I will check out the new code ASAP.

Joe

Update: The new code does not work correctly either. The List Property set has code like this:

//JF 12/22/06 - this code does not work for Csla2.ROC.
//_indexedType = System.Windows.Forms.ListBindingHelper.GetListItemType(value);
//props = System.Windows.Forms.ListBindingHelper.GetListItemProperties(value, null);

_indexedType = System.Windows.Forms.ListBindingHelper.GetListItemType(value);
if (_indexedType.Equals(typeof(object)))
{
props = System.Windows.Forms.
ListBindingHelper.GetListItemProperties(value);
if (props.Count > 0)
{
_indexedType = props[0].ComponentType;
}
}
props =
TypeDescriptor.GetProperties(_indexedType);

===========================================================

But a few months ago you used code like this (which worked):

_indexedType = _list.GetType().GetProperty("Item", new Type[] { typeof(int) }).PropertyType;
============================================================

Why was it changed?

Have you tested it against Csla2 objects?

============================================================

Here are some values from my BO:
TransROC.TransInfo

This ROC has 2 records in it.
==============================================================================================================
  
base
BO.MyReadOnlyBase<BO.TransROC.TransInfo>
{BO.TransROC.TransInfo}

==============================================================================================================

? System.Windows.Forms.ListBindingHelper.GetListItemType(value);

{Name = "IReadOnlyObject" FullName = "Csla2.Core.IReadOnlyObject"}
    [System.RuntimeType]: {Name = "IReadOnlyObject" FullName = "Csla2.Core.IReadOnlyObject"}
    base {System.Reflection.MemberInfo}: {Name = "IReadOnlyObject" FullName = "Csla2.Core.IReadOnlyObject"}
    Assembly: {Csla2, Version=2.1.0.0, Culture=neutral, PublicKeyToken=7cda65b4773872e9}
    AssemblyQualifiedName: "Csla2.Core.IReadOnlyObject, Csla2, Version=2.1.0.0, Culture=neutral, PublicKeyToken=7cda65b4773872e9"
    Attributes: Public | ClassSemanticsMask | Abstract
    BaseType: null
    ContainsGenericParameters: false
    DeclaringMethod: 'System.Windows.Forms.ListBindingHelper.GetListItemType(value).DeclaringMethod' threw an exception of type 'System.InvalidOperationException'
    DeclaringType: null
    FullName: "Csla2.Core.IReadOnlyObject"
    GenericParameterAttributes: 'System.Windows.Forms.ListBindingHelper.GetListItemType(value).GenericParameterAttributes' threw an exception of type 'System.InvalidOperationException'
    GenericParameterPosition: 'System.Windows.Forms.ListBindingHelper.GetListItemType(value).GenericParameterPosition' threw an exception of type 'System.InvalidOperationException'
    GUID: {ed6826ef-59b7-3a57-a538-c69ac3002083}
    HasElementType: false
    IsAbstract: true
    IsAnsiClass: true
    IsArray: false
    IsAutoClass: false
    IsAutoLayout: true
    IsByRef: false
    IsClass: false
    IsCOMObject: false
    IsContextful: false
    IsEnum: false
    IsExplicitLayout: false
    IsGenericParameter: false
    IsGenericType: false
    IsGenericTypeDefinition: false
    IsImport: false
    IsInterface: true
    IsLayoutSequential: false
    IsMarshalByRef: false
    IsNested: false
    IsNestedAssembly: false
    IsNestedFamANDAssem: false
    IsNestedFamily: false
    IsNestedFamORAssem: false
    IsNestedPrivate: false
    IsNestedPublic: false
    IsNotPublic: false
    IsPointer: false
    IsPrimitive: false
    IsPublic: true
    IsSealed: false
    IsSerializable: false
    IsSpecialName: false
    IsUnicodeClass: false
    IsValueType: false
    IsVisible: true
    MemberType: TypeInfo
    Module: {Csla2.dll}
    Namespace: "Csla2.Core"
    ReflectedType: null
    StructLayoutAttribute: null
    TypeHandle: {System.RuntimeTypeHandle}
    TypeInitializer: null
    UnderlyingSystemType: {Name = "IReadOnlyObject" FullName = "Csla2.Core.IReadOnlyObject"}
==============================================================================================================


props {System.ComponentModel.PropertyDescriptorCollection} System.ComponentModel.PropertyDescriptorCollection
 Count 0 int

 

 

 

Brian Criswell replied on Saturday, December 23, 2006

Hi Joe,

I made that change as it allowed me to get away from depending on an IList implementing an Item property.  Arrays do not do that, although I have a special case for arrays.  I started using ListBindingHelper as it allowed for design time support.

I have only ever used this with CSLA 2 because IBindingListView was added in .NET 2.0.  I just tried the ObjectListView on a ReadOnlyListBase with a ReadOnlyBase and it worked fine. What type is your indexer on your read only list defined as?  The debug messages you provided suggest that it is defined as

public IReadOnly this[int index]
{ get; }

Also, the code that you pasted suggests that it is not the code that I posted a couple of days ago.

If you want to send me messages, just use the private message functionality of the boards.  It emails me whenever I get a private message.

JoeFallon1 replied on Thursday, December 28, 2006

Brian,

I looked for the Private Message link before and missed it. I will drop you a line tomorrow.

BTW, My BO is named:
TransROC.TransInfo

and it has a standard Integer Item property inherited from the framework.

The big problem is that your new code thinks the BO is IReadOnly instead of TransROC.TransInfo.

I have no idea why it is doing that.

I will send you more details in the morning.

Joe

 

JoeFallon1 replied on Saturday, December 30, 2006

Brian,

I sent you a PM on this.

The issue is that I have implemented an Interface that includes an overloaded Item Property. See the PM for details.

Joe

 

maurera replied on Tuesday, January 09, 2007

Hey Brian, first let me start by thanking you.  Many of your posts have lent themselves well to understanding some of the nuances of the CSLA.

 

That being said, most of us here at my office are VB .NET developers, and would find it very useful to have a VB version of your ObjectListView.  It appears that some of the CSLA Contrib code has a VB version, but I was unable to locate a VB version of your ObjectListView.  Do you know of anyone that may have such a version?

Brian Criswell replied on Tuesday, January 09, 2007

There is currently not a VB.NET version.  Someone could port it (a lot of code) or you can create a second project in your CSLA solution for C# code, compile and just include the second assembly in your applications.

As the ObjectListView has stabilised, I could port it, but that probably will not happen for a couple of weeks at least.  So you may want to start with the C# version and use the VB version when it becomes available.

maurera replied on Tuesday, January 09, 2007

You would do that for us lowly VB.NET developers ;-)

You, my friend, truly are a rock star.

Gort replied on Wednesday, May 09, 2007

Where can I download the latest ObjectListView classes?  I found them for 1.5.x, is this the latest version?  For some reason I can't find any information on the ObjectListView classes on the contrib site.

Thanks.

Brian Criswell replied on Wednesday, May 09, 2007

http://www.codeplex.com/CSLAcontrib/SourceControl/ListDownloadableCommits.aspx
Go there and download the most recent version.  You should be able to find the necessary files in there.

JoeFallon1 replied on Saturday, June 30, 2007

Brian,

I had an instance of an ObjectListView inside one of my BOs and that broke its ability to be serialized. Is there any reason the ObjectListView is not marked as Serializable?

Joe

 

Brian Criswell replied on Saturday, June 30, 2007

he DataView did not have it, so I did not add it to the ObjectListView.

JoeFallon1 replied on Sunday, July 01, 2007

OK.
I worked around the issue anyway.

===================================================================

I found a small problem with the ObjectListView this morning.

The ObjectViewLibrary is not sorting the way I expect it to.

If all the values are different then it sorts perfectly.

But if some of the values on the original collection are “tied” with each other (e.g. all have the same code) then the sorted view of the collection had the ties in inverted order.

For example:
Original collection has 6 BOs with codes:  A,B, C(1), C(2), C(3), D.

The sorted collection inverts the C’s so it looks like this:  A,B, C(3), C(2), C(1), D.

This makes new rows on the screen get added above existing rows and then screws up databinding as the indexes are out of sequence between the original collection and the sorted list.

I modified the code so that ties are placed at the end of the list and now the sorted list is in the same sequence as the original list.

In the method InsertInOrder I changed:

if (comparison == 0)
{
//_sortIndex.Insert(testIndex, item);
//return testIndex;

//By changing it to continue comparing tied objects we should be able to keep the right order.
return this.InsertInOrder(item, testIndex + 1, highIndex);
}

Joe

 

Brian Criswell replied on Sunday, July 01, 2007

Thanks.  I will add this to CSLAcontrib when I get a chance.

Copyright (c) Marimer LLC