Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
        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;
        }
Exemplo n.º 3
0
        public virtual void Persist(Action del)
        {
            del();

            DuplicateDocument duplicateDocument = DuplicateDocuments.Current;

            if (Setup.Current?.ValidateContactDuplicatesOnEntry == true && duplicateDocument?.IsActive == true)
            {
                CheckForDuplicates.Press();
            }
        }
Exemplo n.º 4
0
        /// <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);
        }