Any changes the way we defined properties in ReadOnlyBase with 3.5

Any changes the way we defined properties in ReadOnlyBase with 3.5

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


GeorgeG posted on Friday, April 11, 2008

For using ReadOnlyBase in 3.5, do we need to do anything different in declaring properties ie use RegisterProperty?
Any of this code changes in 3.5? Is it still the recommented way for ReadOnlyBase?
 private Int32 seqnum = 0;
 public Int32 Seqnum
 {
  get
  {
   return seqnum;
  }
 }

Thanks

 

RockfordLhotka replied on Saturday, April 12, 2008

Your code is fine, but doesn't leverage the authorization capabilities of CSLA .NET 2.0 and higher.

If you want the authorization capabilities you can use the 2.0-3.0 style, or the new 3.5 style:

private static PropertyInfo<int> SeqNumProperty =
  RegisterProperty<int>(typeof(ThisClass), new PropertyInfo<int>("SeqNum"));
private int _seqnum = 0;
public int SeqNum
{
  get { return GetProperty<int>(SeqNumProperty, _seqnum); }
}

But if you don't need authorization then your existing code is also fine.

Copyright (c) Marimer LLC