public bool isChanged() { PropertyInfo[] fields = OldData.GetType().GetProperties(); PropertyInfo[] thisFields = this.GetType().GetProperties(); for (int i = 0; i < fields.Length; i++) { if ((thisFields[i].Name != "Mode") && (thisFields[i].Name != "OldData")) { var current = thisFields[i].GetValue(this, null); var old = fields[i].GetValue(OldData, null); if (current == null) { current = ""; } if (old == null) { old = ""; } if (!current.Equals(old)) { return(true); } } } return(false); }
public CGrid InitOldData() { Mode = TT.NONE; Type type = this.GetType(); OldData = Create(type); PropertyInfo[] fields = type.GetProperties(); PropertyInfo[] oldDataFields = OldData.GetType().GetProperties(); for (int i = 0; i < fields.Length; i++) { if ((oldDataFields[i].Name != "Mode") && (oldDataFields[i].Name != "OldData")) { oldDataFields[i].SetValue(OldData, fields[i].GetValue(this, null), null); } } return(this); }