バージョン

社員

コード例: Employee モデル

コード

C# の場合:

public class Employee : INotifyPropertyChanged
{
    public Employee()
    {
        _directReports = new List<Employee>();
    }
    private string _id = string.Empty;
    public string Id
    {
        get
        {
            return _id;
        }
        set
        {
            if (_id != value)
            {
                _id = value;
                this.OnPropertyChanged("Id");
            }
        }
    }
    private string _name = string.Empty;
    public string Name
    {
        get
        {
            return _name;
        }
        set
        {
            if (_name != value)
            {
                _name = value;
                this.OnPropertyChanged("Name");
            }
        }
    }
    private string _jobTitle = string.Empty;
    public string JobTitle
    {
        get
        {
            return _jobTitle;
        }
        set
        {
            if (_jobTitle != value)
            {
                _jobTitle = value;
                this.OnPropertyChanged("JobTitle");
            }
        }
    }
    private IList<Employee> _directReports;
    public IList<Employee> DirectReports
    {
        get
        {
            return _directReports;
        }
        set
        {
            if (_directReports != value)
            {
                _directReports = value;
                this.OnPropertyChanged("DirectReports");
            }
        }
    }
    public event PropertyChangedEventHandler PropertyChanged;
    protected virtual void OnPropertyChanged(string propertyName)
    {
        if (PropertyChanged != null)
        {
            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}