uNhAddIns.WPF initial draft

34 views
Skip to first unread message

"José F. Romaniello"

unread,
Jul 10, 2009, 12:47:11 PM7/10/09
to unha...@googlegroups.com
I will start with uNhAddIns.WPF

The initial draft is here :
http://jfromaniello.blogspot.com/2009/07/unhaddinswpf-initial-thoughts.html

Please feel free to share with me any comments or opinions.

Fabio Maulo

unread,
Jul 10, 2009, 1:23:27 PM7/10/09
to unha...@googlegroups.com
AFIK INotifyCollectionChanged does not need AOP, rigth ?

2009/7/10 "José F. Romaniello" <jfroma...@gmail.com>



--
Fabio Maulo

"José F. Romaniello"

unread,
Jul 10, 2009, 2:13:40 PM7/10/09
to unha...@googlegroups.com
No it doesn't, you are right.

Fabio Maulo escribió:


> AFIK INotifyCollectionChanged does not need AOP, rigth ?
>
> 2009/7/10 "José F. Romaniello" <jfroma...@gmail.com

> <mailto:jfroma...@gmail.com>>

"José F. Romaniello"

unread,
Jul 13, 2009, 4:09:17 PM7/13/09
to unha...@googlegroups.com
I'm looking for opinions about this subject..
EnhancedBytecode provider and the ReflectionOptimizer works great to
resolve entities with the IoC container. However, there are some cases
that is not enough.
For instance, when you add a custom interceptor, or an additional
interface the container will resolve as a "Proxy32132131232132", in such
cases nhibernate can't find a suitable persister.
From here I will talk only for castle adapters.

My workarround will be to add a:
-GetNameInterceptor (Method Call Interceptor - Castle)
-INhibernateNamedEntity (additional interface for this kind of
components)
-EntityNameInterceptor (Nhibernate Interceptor)
-Maybe an InterceptorSelector

This solution is extracted from
http://fabiomaulo.blogspot.com/2008/10/less-than-few-is-gof.html.

Thoughts?

Fabio Maulo escribió:


> AFIK INotifyCollectionChanged does not need AOP, rigth ?
>
> 2009/7/10 "José F. Romaniello" <jfroma...@gmail.com

> <mailto:jfroma...@gmail.com>>

Chris Nicola

unread,
Jul 14, 2009, 11:55:41 PM7/14/09
to uNhAddIns
I would be very interested in using something like this, though I
wonder of some people will feel that introducing UI concerns in the
domain would be polluting the domain?

For my last project I used nHibernate with a WPF UI and it worked out
extremely well. I ended up using MVVM and viewmodels which
encapsulated the data from my entities. I had a ViewModelBase class
implementing some custom IEditiableObject logic and I used
INotifyProperty changed on the viewmodels, which is a standard
requirement for a viewmodel though only for a total undo, not N undo/
redo.

I did however make some early attempts at binding entities directly by
having them inherit a base class that implemented
INotifyPropertyChanged and adding PropertyChanged("PropertyName") to
all my properties. I definitely see the potential creating nHibernate
entities that implement INotifyPropertyChanged and IEditableObject and
binding directly WPF UserControl views.

Another idea might be providing save/update and delete as ICommand
(s). Also a sort of build in lazy-loading functionality for entities
with one-to-many relationships would be another. I implemented my
lazy loading in the viewmodel so that when the collection was accessed
it would perform a query for it. I find the trickiest thing about
nHibernate and WPF is determining the best way to manage your sessions
and where, having that handled in a sensible manner for a WPF app
would be a dream.

I'm looking forward to hearing some more of your ideas for WPF-aware
entities. I can see a lot of potenitial for this. I would be very
happy to contribute if I can in any way.

Fabio Maulo

unread,
Jul 15, 2009, 12:07:01 AM7/15/09
to unha...@googlegroups.com
Chris, I think that the session management here, for José, is the last preoccupation: CpBT.

2009/7/15 Chris Nicola <chni...@gmail.com>



--
Fabio Maulo

"José F. Romaniello"

unread,
Jul 15, 2009, 9:09:33 AM7/15/09
to unha...@googlegroups.com
Chris Nicola escribió:

> I would be very interested in using something like this, though I
> wonder of some people will feel that introducing UI concerns in the
> domain would be polluting the domain?
>
Yes, I know that and this is something that I am taking into account. I
want t show you two classes:

http://unhaddins.googlecode.com/svn/trunk/uNhAddIns/uNhAddIns.WPF.Tests/Collections/SampleDomain/Album.cs
http://unhaddins.googlecode.com/svn/trunk/uNhAddIns/uNhAddIns.WPF.Tests/EditableBehaviorIntegration.cs

As you can see Album hasn't UI stuff. Entity is a class from unhaddins
that has some nice stuff but none of them related to UI.


> For my last project I used nHibernate with a WPF UI and it worked out
> extremely well. I ended up using MVVM and viewmodels which
> encapsulated the data from my entities. I had a ViewModelBase class
> implementing some custom IEditiableObject logic and I used
> INotifyProperty changed on the viewmodels, which is a standard
> requirement for a viewmodel though only for a total undo, not N undo/
> redo.
>

You could look the above sample, this will be supported. Note that also
you could add another interface to the proxy, lets say :
Public interface IEditableAlbum : IEditableObject, IAlbum {}

> I did however make some early attempts at binding entities directly by
> having them inherit a base class that implemented
> INotifyPropertyChanged and adding PropertyChanged("PropertyName") to
> all my properties. I definitely see the potential creating nHibernate
> entities that implement INotifyPropertyChanged and IEditableObject and
> binding directly WPF UserControl views.
>

INotifyPropertyChanged is another behavior, you could see my post on the
subject...
http://jfromaniello.blogspot.com/2009/07/inotifypropertychanged-as-aop.html
It will work like IEditable. So you can plug:
public interface INotificableEditableAlbum : IEditableObject,
INotifyPropertyChanged, IAlbum

> Another idea might be providing save/update and delete as ICommand
> (s).

I think that ICommand is related to View -> ViewModel comunication and has nothing to do with the Model itself.

> Also a sort of build in lazy-loading functionality for entities
> with one-to-many relationships would be another. I implemented my
> lazy loading in the viewmodel so that when the collection was accessed
> it would perform a query for it.

Is one of the reason that I will not "encapsulate" domain entities with
an extra model, let nhibernate deal with lazy loading and bind directly
to domain entities.

> I find the trickiest thing about
> nHibernate and WPF is determining the best way to manage your sessions
> and where, having that handled in a sensible manner for a WPF app
> would be a dream.
>

Like Fabio said; CpBT.


> I'm looking forward to hearing some more of your ideas for WPF-aware
> entities. I can see a lot of potenitial for this. I would be very
> happy to contribute if I can in any way.
>
>

Finally, thank you very mutch for your comments and the comment on my
blog, stay in touch with this project.
It is *very*, very, very important for me to read opinions.

Reply all
Reply to author
Forward
0 new messages