public NoDuplicates(IPropertyInfo primaryProperty, IPropertyInfo idProperty, CheckForDuplicates duplicateCommand) : base(primaryProperty) { if (primaryProperty == null) { throw new ArgumentException("primaryProperty cannot be null."); } if (idProperty == null) { throw new ArgumentException("idProperty cannot be null."); } if (duplicateCommand == null) { throw new ArgumentException("duplicateCommand cannot be null."); } if (primaryProperty.Type != typeof(string)) { throw new ArgumentException("primaryProperty must be a string."); } if (idProperty.Type != typeof(int)) { throw new ArgumentException("idProperty must be an int."); } this.IdPropertyName = idProperty.Name; this.InputProperties = new List<IPropertyInfo> { primaryProperty, idProperty }; this.DuplicateCommand = duplicateCommand; }
public NoDuplicates(IPropertyInfo primaryProperty, IPropertyInfo idProperty, CheckForDuplicates duplicateCommand) : base(primaryProperty) { if (primaryProperty == null) { throw new ArgumentException("primaryProperty cannot be null."); } if (idProperty == null) { throw new ArgumentException("idProperty cannot be null."); } if (duplicateCommand == null) { throw new ArgumentException("duplicateCommand cannot be null."); } if (primaryProperty.Type != typeof(string)) { throw new ArgumentException("primaryProperty must be a string."); } if (idProperty.Type != typeof(int)) { throw new ArgumentException("idProperty must be an int."); } this.IdPropertyName = idProperty.Name; this.InputProperties = new List <IPropertyInfo> { primaryProperty, idProperty }; this.DuplicateCommand = duplicateCommand; }
public virtual void Persist(Action del) { del(); DuplicateDocument duplicateDocument = DuplicateDocuments.Current; if (Setup.Current?.ValidateContactDuplicatesOnEntry == true && duplicateDocument?.IsActive == true) { CheckForDuplicates.Press(); } }
/// <summary> /// Generates alphanumeric tokens of the required length, such that there is no other existing token /// as per the supplied list. Result is a combination of letters /// and upper-case characters. Tricky letters like O, L and I are excluded. /// </summary> /// <param name="length">The length of the token</param> /// <param name="duplicateFound">Method that will check if the newly generated token already exists.</param> /// <returns></returns> private static string GenerateToken(int length, CheckForDuplicates duplicateFound) { string token; if (duplicateFound == null) { throw new Exception("Please provide a method to check for duplicates"); } do { token = Create(length); } while (duplicateFound(token)); return(token); }