using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CloudBuilder.Gui { public class ExFormSnapshotEntry { public string ControlName { get; set; } public string DataPropertyName { get; set; } public string DisplayName { get; set; } public string DisplayValue { get; set; } public object Value { get; set; } // Methods public ExFormSnapshotEntry() { } public ExFormSnapshotEntry(string controlName, string displayName, object value, string displayValue) : this(controlName, displayName, value, displayValue, null) { } public ExFormSnapshotEntry(string controlName, string displayName, object value, string displayValue, string dataPropertyName) { ControlName = controlName; DisplayName = displayName; DisplayValue = displayValue; Value = value; DataPropertyName = dataPropertyName; } private static bool IsNull(object value) { if (value == null) return true; if (value is string) return string.IsNullOrEmpty((string)value); if (value is DBNull) return true; return false; } public static bool Compare(object v1, object v2) { bool b1 = IsNull(v1); bool b2 = IsNull(v2); if (b1 == b2 && b1 == true) return true; return v1.Equals(v2); } public ExFormSnapshotDifferenceEntry Compare(ExFormSnapshotEntry o) { if (!Compare(this.Value, o.Value)) { return new ExFormSnapshotDifferenceEntry(this.ControlName, this.DisplayName, this.Value, this.DisplayValue, o.Value, o.DisplayValue, this.DataPropertyName); } return null; } } }