PropertyChanged Not raised on one specific BO. Any idea where to look at?

PropertyChanged Not raised on one specific BO. Any idea where to look at?

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


arobadol posted on Monday, August 16, 2010

Daer all,

I'm still working on my Caliburn/CSLa Application. the integration works fine. I have encouter an issue that maybe you will be able to solve easily...

This is not my first BO and I do not understand why whit this specific one The porperty changed is not raised.

I have a BO Office which inherits from Business Base. When I change a property the PropertyChanged event is raised.

the property is declared as the following

[Serializable]
public class Office : BusinessBase<Office>
{

#region Business Methods
 
private static PropertyInfo<Guid> IdProperty = RegisterProperty<Guid>(p => p.Id);
public Guid Id
{
    get { return GetProperty(IdProperty); }
    private set { SetProperty(IdProperty, value); }
}

private static PropertyInfo<string> NameProperty = RegisterProperty<string>(p => p.Name);
public string Name
{
    get { return GetProperty(NameProperty); }
    set { SetProperty(NameProperty, value);}

} ......
 

If I use the following unit code I can break on the Property changed code

 
AutoResetEvent _testTrigger;
[TestMethod]
public void OfficePropertyChangedTest()
{
 Office office = null;
 _testTrigger = new AutoResetEvent(false);
 var dp = new DataPortal<Office>();
 dp.CreateCompleted += (o, e) =>
 {
  office = e.Object;
  _testTrigger.Set();
 };
 dp.BeginCreate(); 
 _testTrigger.WaitOne();

 office.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(office_PropertyChanged);

 office.Name = "Hello";
 _testTrigger.WaitOne();

}

void office_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{          
 //Break here works...
  _testTrigger.Set();    
}

 

But on my other BO Voucher... It does not :(

  [Serializable]
     public class Voucher : BusinessBase<Voucher>
     {

         #region Business Property

         private static PropertyInfo<Guid> IdProperty = RegisterProperty<Guid>(p => p.Id);
         public Guid Id
         {
              get { return GetProperty(IdProperty); }
              private set { LoadProperty(IdProperty, value); }
         }

         private static PropertyInfo<int> NumberProperty = RegisterProperty<int>(p => p.Number);
         public int Number
         {
              get { return GetProperty(NumberProperty); }
              set { LoadProperty(NumberProperty, value); }
         }...

 

the following Unit test code is used...

AutoResetEvent _testTrigger;
[TestMethod]
public void VoucherPropertyChangedTest()
{
 Voucher voucher = null;
 _testTrigger = new AutoResetEvent(false);
 
 var dp = new DataPortal<Voucher>();
 dp.CreateCompleted += (o,e)=>
 {
  voucher = e.Object;
  _testTrigger.Set();
 };

 dp.BeginCreate();
 _testTrigger.WaitOne();

 voucher.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(voucher_PropertyChanged);

 voucher.Number = 123;

 _testTrigger.WaitOne();

}

void voucher_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
 //Break is not reached... Any idea????
 _testTrigger.Set();
}

 

thanks for your help.

 

arobadol replied on Monday, August 16, 2010

Found the problem... :)

 

I was using LoadProperty in the set instead of Set...

 

tiago replied on Sunday, January 09, 2011

arobadol

Daer all,

I'm still working on my Caliburn/CSLa Application. the integration works fine.

Hi arobadol,

I intend to use Caliburn with WPF. To be more precise, Caliburn Micro. Have you tryed Caliburn Micro?

Regards,

arobadol replied on Monday, January 10, 2011

Dear Tiago,

 

I was pleased with the integration I did with CSLA and Caliburn 1.1. I'm now porting it to Caliburn 1.2 and some concepts have evolved So I will have to adapt my foundations :(.

I have no experience with Caliburn Micro but from what I read about it they will probably integrate together the same way they will integrate with Caliburn 1.2.

I beleive the integration I did with Cliburn 1.1 will be quite different.

 

I'll keep you informed when I will be closer to something usefull.

 

Regards.

Copyright (c) Marimer LLC