lundi 18 mars 2019

How to update server property on updating client property

I have two equal classes on both sides of WCF communication:

public class UserInfo
{
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public int Age { get; set; }
    ....
}

One client's class update I need to update the service's class. I can implement a WCF service with methods:

public interface IUserInfoUpdateContract
{
   void UpdateFirstName(string value);
   void UpdateLastName(string value);
   void UpdateAge(string value);
   ...
}

But, is there an alternative way how I can update properties dynamically? E.g.:

public interface IUserInfoUpdate
{
   void UpdateProperty(string propertyName, object propertyValue);
}

Usage on client side:

public class UserInfo
{
    private string _firstName;
    public string FirstName 
    { 
        get { return _firstName; }
        set 
        { 
            _firstName = value;
            wcfClient.UpdateProperty(nameof(FirstName), FirstName);
        }
    }
}

Do I have any options how to dynamically update the properties on service side without Reflection?





Aucun commentaire:

Enregistrer un commentaire