Use of partial classes for CslaIdentity and MembershipIdentity in framework

Use of partial classes for CslaIdentity and MembershipIdentity in framework

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


skagen00 posted on Tuesday, October 27, 2009

Is there a particular reason that I'm missing as to why these classes leverage partial classes (one partial for .NET side, one partial for Silverlight side, and one shared file) and not compiler directives like everything else in the framework and the samples (at least that I've seen).

I'm sure it's probably been asked before and it's a little thing but I've never noticed it in the first place and was curious.

RockfordLhotka replied on Tuesday, October 27, 2009

When we build CSLA .NET for Silverlight we were learning - remember that we started this project before SL2 was released.

So we did some work with compiler directives, and some with partial classes. I even started a thread on the forum at the time to solicit input from the broader community.

In the end most of the framework code uses compiler directives, because that really does turn out to be the cleaner solution overall (at least in C# where the IDE collapses the part that doesn't apply) for framework code.

However, I still use partial classes in my business library code, because I think it provides cleaner separation, especially for things like sync factory methods, any data access region, etc. Things that have absolutely no meaning on one side of the wire.

Copyright (c) Marimer LLC