mmmm PropertyAccessor for collection ? Perhaps I don't understand well... btw in NH2.1.0 you have an injectable ICollectionTypeFactory to create collections implementing whatever you want. An example is here http://code.google.com/p/unhaddins/source/browse/trunk/uNhAddIns/uNhAddIns.WPF/Collections/WpfCollectionTypeFactory.cs
2009/8/9 mathmax <[email protected]> > > Hello, > > I've created my own class (inherited from IPropertyAccessor) to load > custom collections (via the access attribute in the mapping file). > With nh 1.2, I was able to load property of type > ObservableCollection<T> using this class. > Now with nhibernate 2.1 I get "Object reference not set to an instance > of an object" in this method (next to last line): > > public override void Set(object target, object value) > { > var initializedField = typeof(AbstractPersistentCollection).GetField > ("initialized", BindingFlags.NonPublic | BindingFlags.Instance); > bool savedInitializedFieldValue = (bool) initializedField.GetValue > (value); > > initializedField.SetValue(value, true); > propertyInfo.SetValue(target, Activator.CreateInstance > (fieldInfo.FieldType, (IList<T>)value), null);//ERROR HERE : value's > type is NHibernate.Collection.Generic.PersistentGenericBag<T> but I > cannot look at the items (Object reference not set to an instance of > an object). > initializedField.SetValue(value, savedInitializedFieldValue); > } > > You can look at the full code of my class here: > http://www.mynetdomain.de/mathmax/CollectionAccessor.htm > > What is very strange is that I don't get any error when I set a > breakpoint on the first line of Set() and execute it until all > properties have been loaded. I really don't understand why the > breakpoint "solve" the problem... > > Does anyone understand what happens? Is there any changes in the way > nhibernate 2.1 deals with IPropertyAccessor implementations? > > > -- Fabio Maulo --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
