using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.ComponentModel; using System.Reflection; namespace WpfApplication19 { class MeasurePoint : INotifyPropertyChanged { #region INotifyPropertyChanged Members public event PropertyChangedEventHandler PropertyChanged; protected void Notify(string propName) { if (this.PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propName)); } } #endregion /* private int _P1; public int P1 { get { return _P1; } set { this._P1 = value; Notify("P1"); } } */ public int Count { get; set; } public double P1 { get; set; } public double P2 { get; set; } public double P3 { get; set; } public double P4 { get; set; } public double P5 { get; set; } public double P6 { get; set; } public double P7 { get; set; } public double P8 { get; set; } public double P9 { get; set; } public double P10 { get; set; } public double Avg { get; set; } public string Grade { get; set; } public string ResultGrade { get; set; } public string Type { get; set; } public int SubOrder { get; set; } public void setValue(string alias, double value) { PropertyInfo methodInfo = typeof(MeasurePoint).GetProperty("P"+alias); // Use the instance to call the method without arguments try{ int cn = Convert.ToInt16(alias); if (cn >= 1 && cn <= 10) methodInfo.SetValue(this, value, null); }catch{ return; } } public float GetValue(string alias) { PropertyInfo methodInfo = typeof(MeasurePoint).GetProperty(alias); return (float)methodInfo.GetValue(this, null); } } }