Using optional private field param to register property to waive loadProperty

CSLA .NET 3.5 property declaration syntax

CSLA .NET 3.5 also supports a different syntax where you use private fields to store the values. This technique is faster than using managed fields, but requires that you declare and maintain your own fields. The syntax for declaring such a property is here.

One thing I figured out is, by using this new syntax means you are not going to use LoadProperty method anymore, because the method getter only use managed field to store staus/flag, the actual value of the property will always return from the private field.

Another word, the value stored in managed field/Property Info object is useless if you are using

get { return GetProperty<string>(NameProperty, _name); }

in your property getter.

About these ads

Moving to TFS

Our current VSS works fine, but we are going to move to TFS anyway. The reasons are:

  1. VSS has no permission configuration, a developer can change any work item in source repository.
  2. VSS has no policy. Like code review before check in.
  3. VSS is slow. No real server behind.

But, the test result on TFS is good as we expected.

  1. No sharing anymore.
    We figured out Microsoft is trying to promote Branching and Merging instead of simple sharing. So our cooperation code will need 3branches at least: one for DEV, one for Acceptance, and one for Production/Release. All other projects will branch the latest version of Production/Release. Until the cooperation code is merging (for us, it’s just a deploy or copying) into the Acceptance/Production/Release branch, outside developer won’t see those unstable/untested code. Fine, I like this idea. Bye bye, sharing.
  2. Explore client.
    This is the new client for developer. If developer’s machine already has VisualStudio installed, it will become a plugin, otherwise it’s a standalone application looks like VisualStudio, but only TFS view in it.
  3. MSSCCI provider.
    It’s needed for PB developing. For orcascript, I had to modify registry to shorten the string name, because Orcascript only can handle 34 chars in SCC name. Thanks to Ronarld Smith’s post.

    scc set connect property provider “Microsoft Team Foundation Server”
    scc set connect property userid “DomainName\LoginId”
    scc set connect property project “$/ProjectName”
    scc set connect property auxproject “http://tfs-servername:portnumber&#8221;
    scc set connect property localprojpath “C:\work_dir\”
    scc set connect property logfile “buildfromsource.log”
    scc set connect property logappend false

  4. Dreamweaver.
    Doesn’t support.
  5. EClipse.
    There is a plugin develped by TeamPrise. Not free.
  6. Slow Refresh in PowerBuilder.
    It seems this is a big problem for those PB+TFS developers, for me it’s 4 times slower than VSS. Why?
  7. CC.net plugin.
    It’s available. Check the help file in CC.net.
    Watch out the wrong example there:

    <deleteWorkspace>false</workspace>

Rollback db unit test

I couldn’t make Roy’s XtUnit working in my test cases. Tried to switch to MbUnit, but Resharper 4 still doesn’t support it yet. Later, I found there are some posts (here, and here) pointing out the very easy solution for this: System.Transactions.TransactionScope.

I then adopt this trick, created my own DBTestFixtureInTheRollBackTransactionclass.

It works, and like the author said, embarrassingly simple!

Set default value to detailsView

This is an ASP.net issue. User control is great, when it works. But you have to spend more time on it when some feature you are not sure how to. Like this one, how to set the default value for a new insert record on detailsView?

This won’t be a problemfot regular textbox, but for user control I had to look into the junk of properties. Finally, I did it. The trick is, “Convert this field into a TemplateField” in edit fields detailsView.

Original, the layout code was:

<asp:BoundField DataField=”OrganizationStatus” HeaderText=”OrganizationStatus”
SortExpression=”OrganizationStaus” />

After conerting:

<EditItemTemplate>
<asp:TextBox ID=”TextBox1″ runat=”server”
Text=’<%# Bind(“OrganizationStatus”) %>’></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID=”TextBox1″ runat=”server”
Text=’<%# CurrentOrganization.OrganizationStatus %>’></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID=”Label1″ runat=”server” Text=’<%# Bind(“OrganizationStatus”) %>’></asp:Label>
</ItemTemplate>

Notice I’ve already changed the bind value in ‘InsertItemTemplate’ from Bind(“OrganizationStatus”) to CurrentOrganization.OrganizationStatus, which is a property of View. What a brilliant idea, MVP!

Credits to this post.

Other solutions like calling “DetailsView1.Rows[n].Cells[n].Text = xxx” in DetailsView1_PreRender didn’t fix the problem perfectly. They migaiccly changed the textbox to lable!

StructureMap Registry in WCF

Following the post by Jimmy Bogard,  with Oran’s example, I figured this out finally. So I can remove the xml config file for both winForm and WCFHost.

I was wondering how to do the similar process in WCF just like appStart in WinForm, even it was so complicated, but it’s feasible, by implementing my own wcf service Factory.

It works with CSLA just like a charm. The only thing you should keep in mind is, in unit-test, still use ObjectFactory.Inject(). Don’t try to touch registry unitll you want to test registry configuration itself.

Config file for LinQToSql dbml

Rick’s post is the best one I found so far to explain the configuration file for LinQtoSql dbml. My experience is:

  1. Don’t set user’s password in your linqtosql dbml at the very beginning. Figure this configuration magic out first before everything starts.
  2. The “Settings Property Name” key in Connection section itself can give enough information. You need to add a same name connection string in your app config file, but watch out if you are in N-Tier development mode, which means your DAL lib is in different assembly. In that case, you need to use the full typed name “key” (with the DAL name space as the pre-fix) as the connection string name, as Rick emphasised.