mardi 3 janvier 2017

Setvalue for class inside another class's property using reflection

I have a class structure as below

public class Container
    {
        public DataField<string> Name { get; set; }
        public List<Address> Addresses { get; set; }
    }

public class Address
    {
        public string AddressLine1 { get; set; }
        public string AddressLine2 { get; set; }
    }

public class DataField<T> : INotifyPropertyChanged
    {
        T m_value;

        public T Value
        {
            get
            {
                return m_value;
            }
            set
            {
                m_value = value;
                OnPropertyChanged("Value");
            }
        }
}

Then i have created instance for Container

Container _item = new Container();
_item.Name = new DataField<string>("");

i need set value

`string _strValue = "Value is 0";

variable value into

_item.Name.Value

Please anyone help me on this





Aucun commentaire:

Enregistrer un commentaire