What is the difference between IPatternApplier<Type, IJoinedSubclassAttributesMapper> and AfterMapJoinedSubclass ?

15 views
Skip to first unread message

Plácido Monteiro Dinelli Bisneto

unread,
Jul 24, 2011, 6:07:30 PM7/24/11
to codec...@googlegroups.com
Hi!

I'm starting to use the confORM and I'm loving it! For real! :)
But I was trying things here and I found out that I can customize the <key column=""> value using both methods.
First one is doing this:

public class JoinedClassColumnNameApplier : IPatternApplier<Type, IJoinedSubclassAttributesMapper>
{
public void Apply(Type subject, IJoinedSubclassAttributesMapper applyTo)
{
applyTo.Key(km => km.Column(subject.Name + "Id"));
}

public bool Match(Type subject)
{
return true;
}
}

and doing this:

void mapper_AfterMapJoinedSubclass(IDomainInspector domainInspector, Type type, IJoinedSubclassAttributesMapper joinedSubclassCustomizer)
{
joinedSubclassCustomizer.Key(
key =>
{
key.ForeignKey(type.BaseType.Name + "Id" + "To"+type.Name);
key.Column(x =>
{
x.Name(type.Name + "Id");

});
});
}

But, is there any difference? Or it's just another way to do the same thing?!
Thanks in advance!

PS: Fabio, congratulations man. You're the best! :)

Fabio Maulo

unread,
Jul 26, 2011, 8:10:32 AM7/26/11
to codec...@googlegroups.com
There is a really big difference.
1) a pattern-applier is a re-usable class
2) a pattern-applier can be added to your set of patterns (IPatternsAppliersHolder)
3) a pattern-applier can be merged to an existing set of patterns (CoolPatternsAppliersHolder)
4) a pattern-applier is easy to test
5) a pattern-applier is applied after execute BeforeMapXYZ event and before execute AfterMapXYZ

2011/7/24 Plácido Monteiro Dinelli Bisneto <cid...@live.com>



--
Fabio Maulo

Reply all
Reply to author
Forward
0 new messages