public void Hydrate(IXMLSavable iXMLSavable) { if (iXMLSavable is Country country) { Id = country.Id; Name = country.Name; Iso2 = country.Iso2; Iso3 = country.Iso3; } }
public void Hydrate(IXMLSavable iXMLSavable) { if (iXMLSavable is Competition competition) { Id = competition.Id; Name = competition.Name; StartDate = competition.StartDate; EndDate = competition.EndDate; CreatedAt = competition.CreatedAt; UpdatedAt = competition.UpdatedAt; } }
public void Hydrate(IXMLSavable iXMLSavable) { if (iXMLSavable is Result result) { Serie1 = result.Serie1; Serie2 = result.Serie2; Serie3 = result.Serie3; Serie4 = result.Serie4; ShootedBy = result.ShootedBy; CreatedAt = result.CreatedAt; UpdatedAt = result.UpdatedAt; } }
public void Hydrate(IXMLSavable iXMLSavable) { if (iXMLSavable is User user) { Id = user.Id; Firstname = user.Firstname; Lastname = user.Lastname; Email = user.Email; Password = user.Password; CreatedAt = user.CreatedAt; UpdatedAt = user.UpdatedAt; } }
public void Hydrate(IXMLSavable iXMLSavable) { if (iXMLSavable is Shooter shooter) { Id = shooter.Id; Firstname = shooter.Firstname; Lastname = shooter.Lastname; Birthday = shooter.Birthday; Nationality = shooter.Nationality; CreatedAt = shooter.CreatedAt; UpdatedAt = shooter.UpdatedAt; } }
// USED WHEN ADDING ONE ELEMENT TO A FILE, ON ORDER TO CHECK THAT IT DOESNT GO AGAINST THE CONSTRAINTS OF THE FILE public static void VerifyConstraints <T>(string filename, IXMLSavable elemToVerify) where T : IXMLSavable { foreach (Constraint constraint in Constraints.WakeUp().GetDataFileConstraints(filename)) { if (constraint.Type == ConstraintsTypes.UNIQUE) { object elemToVerifyValue = typeof(T).GetProperty(constraint.Field).GetValue(elemToVerify); Dictionary <string, object> search = new Dictionary <string, object>(); search.Add(constraint.Field, elemToVerifyValue); List <T> results = Find <T>(filename, search); if (results.Count() >= 1) { throw new ValueInUniqueFieldAlreadyTaken("A row already exists with the field « " + constraint.Field + " » containing the value « " + elemToVerifyValue.ToString() + " ». Insertion in file « " + constraint.DataFile + ".xml » have been cancelled."); } } } }