Exemplo n.º 1
0
 /// <summary>
 /// Resets validation status to not validated on the object and the criteria object, if any.
 /// </summary>
 public override void ResetAllValidation()
 {
     ResetValidation();
     if (CriteriaObject != null)
     {
         CriteriaObject.ResetAllValidation();
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Gets all validation errors from the data list object and the criteria object, if any.
        /// </summary>
        /// <returns>Validation errors from the data list object and the criteria object.</returns>
        public override ErrorList GetValidationErrors()
        {
            ErrorList errLst = new ErrorList();

            if (validationErrorList != null)
            {
                errLst.MergeWith(validationErrorList);
            }
            if (CriteriaObject != null)
            {
                errLst.MergeWith(CriteriaObject.GetValidationErrors());
            }
            return(errLst);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Validates the data list object and the criteria object, if any.
        /// </summary>
        /// <param name="force">True to validate regardless of whether or not it has been already validated.</param>
        public override void Validate(bool force)
        {
            if (CriteriaObject != null)
            {
                CriteriaObject.Validate(force);
            }

            if (force)
            {
                ResetValidation();
            }
            if (validationErrorList != null)
            {
                return;
            }

            validationErrorList = new ErrorList();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Populates the data object list and imports the data from the given data contract list
        /// with ability to preserve currently selected entities.
        /// </summary>
        /// <param name="dataContract">Enumeration of data contract objects to populate the list from.</param>
        /// <param name="options">Additional options for the operation.</param>
        public override void FromDataContract(object dataContract, object options)
        {
            IEnumerable list = dataContract as IEnumerable;

            if (list == null)
            {
                return;
            }
            List <DataRow>      sel  = new List <DataRow>();
            ListSortCriteria    keys = new ListSortCriteria();
            PopulateListOptions opts = options as PopulateListOptions;

            if (opts != null && opts.PreserveSelection)
            {
                sel = SelectedRows;
                keys.AddRange(Properties.Where(p => p.IsKey).Select(p => new ListSortField()
                {
                    PropertyName = p.Name
                }));
            }
            data.Clear();
            Reset();
            SetModified(false, false);
            foreach (object contractItem in list)
            {
                DataRow r = new DataRow(this);
                data.Add(r);
                MoveNext();
                base.FromDataContract(contractItem, options);
                r.Selected = sel.Any(s => SameEntity(s, r, keys));
            }
            if (CriteriaObject != null)
            {
                AppliedCriteria = CriteriaObject.GetFieldCriteriaSettings();
            }
            FireCollectionChanged();
            FireSelectionChanged();
        }