using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; namespace PEP_Tool { public class TableInfo : INotifyPropertyChanged, IEquatable { public event PropertyChangedEventHandler PropertyChanged; private string filePath; public string FilePath { get { return filePath; } set { filePath = value; OnPropertyChanged(); } } //public string FilePath { get; set; } public string Name { get; set; } public string Vorname { get; set; } public string Schicht { get; set; } public DateTime Datum { get; set; } public string PersNummer { get; set; } public string Gehen { get; set; } public string Abteilung { get; set; } public string Tagescode { get; set; } public string Arbeitsmuster { get; set; } public string Beginn { get; set; } public List Lizenzen { get; set; } private string zuweisung; public string Zuweisung { get { return zuweisung; } set { zuweisung = value; OnPropertyChanged(); } } public List ZuweisungsMoeglichkeiten { get; set; } private string bemerkung; public string Bemerkung { get { return bemerkung; } set { bemerkung = value; OnPropertyChanged(); } } private string telefon; public string Telefon { get { return telefon; } set { telefon = value; OnPropertyChanged(); } } public List Schaltung { get; set; } private string zugname; public string ZugName { get { return zugname; } set { zugname = value; OnPropertyChanged(); } } public void Clear() { FilePath = ""; //Count = 0; //Row = 0; //Column = 0; Name = ""; Vorname = ""; Schicht = ""; Datum = DateTime.Parse("01.01.1900 00:00"); PersNummer = "0"; Gehen = ""; Abteilung = ""; Tagescode = ""; Arbeitsmuster = ""; Beginn = "";// TimeSpan.FromSeconds(0); Lizenzen = null; } public object GetPropertyValueForID(int ID, TableInfo type) { //System.Diagnostics.Debug.WriteLine(type.GetType().GetProperty("Name").GetValue(type, null)); switch (ID) { case 1: return type.GetType().GetProperty("Name").GetValue(type, null); break; case 2: return type.GetType().GetProperty("Vorname").GetValue(type, null); break; case 3: return type.GetType().GetProperty("Datum").GetValue(type, null); break; case 4: return type.GetType().GetProperty("Abteilung").GetValue(type, null); break; case 5: return type.GetType().GetProperty("Zuweisung").GetValue(type, null); break; case 6: return type.GetType().GetProperty("Bemerkung").GetValue(type, null); break; case 7: return type.GetType().GetProperty("FilePath").GetValue(type, null); break; case 8: return type.GetType().GetProperty("Schicht").GetValue(type, null); break; case 9: return type.GetType().GetProperty("PersNummer").GetValue(type, null); break; case 10: return type.GetType().GetProperty("Gehen").GetValue(type, null); break; case 11: return type.GetType().GetProperty("Tagescode").GetValue(type, null); break; case 12: return type.GetType().GetProperty("Arbeitsmuster").GetValue(type, null); break; case 13: return type.GetType().GetProperty("Beginn").GetValue(type, null); break; case 14: return type.GetType().GetProperty("Lizenzen").GetValue(type, null); break; } return null; } #region EqualityComparer // Overriding Equals member method, which will call the IEquatable implementation // if appropriate. // This is the method that must be implemented to conform to the // IEquatable contract public bool Equals(TableInfo other) { if (other == null) { return false; } //if (ReferenceEquals(this, other)) //{ // return true; //} if (this.PersNummer != other.PersNummer) return false; if (this.Datum != other.Datum) { return false; } if (this.Zuweisung != other.Zuweisung) { return false; } if (this.Bemerkung != other.Bemerkung) { return false; } return true; } public override bool Equals(object obj) => Equals(obj as TableInfo); public override int GetHashCode() => (PersNummer + Datum.ToString()).GetHashCode(); //public class TableInfoZuweisungComparer : IEqualityComparer //{ // public bool Equals(TableInfo x, TableInfo y) // { // if ((x.PersNummer == y.PersNummer) // && (x.Datum == y.Datum) // && (x.Zuweisung == y.Zuweisung)) // return true; // else return false; // } // public int GetHashCode(TableInfo obj) // { // return obj.PersNummer.GetHashCode(); // } //} #endregion private void OnPropertyChanged([CallerMemberName] string propertyName = null) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } } }