Hi,
I'm trying to separate actual service data from service functionality and am therefore returning data as a data contract which holds several properties (data members). The client code is generated using svcutil /edb which also generates an INotifyPropertyChanged implementation for the proxy code. As far as my testing revealed, that code does not invoke the PropertyChanged event for changes which happened on the server. Additionally, getting a property does only return the property value as when the data contract proxy has been obtained.
Basically, here is what I've got:
(Server Side)
[ServiceContract]
public interface IControllerService
{
[OperationContract]
DataModel GetDataModel();
}
[DataContract]
public class DataModel : INotifyPropertyChanged
{
private string _state;
[DataMember]
public string State
{
set
{
if (_state != value)
{
_state = value;
OnPropertyChanged("State");
}
}
get
{
return _state;
}
}
public event PropertyChangedEventHandler PropertyChanged;
[OperationContract]
protected virtual void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
(Client Side)
private void Test()
{
ControllerServiceClient client = new ControllerServiceClient();
DataModel model = client.GetDataModel();
model.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(DataModelChanged);
Console.WriteLine(model.State);
// ... invoke something that forces the server to change the data model
// Output stays the same
Console.WriteLine(model.State);
}
private void DataModelChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
// This method never get called for server-side changes
}
I expect that the data contract proxy acts as a transparent proxy to the server's data contract but it seems to be completely unbound.
Thanks very much beforehand, Cheers,
Romout