/// <summary>
        /// Returns whether the current data context can currently be saved to the store.
        /// </summary>
        bool ISaveable.CanSave(AppPrincipal contextUser, IList <ErrorResult> errors)
        {
            bool result = false;

            if (_validator != null)
            {
                if (_validator.CanAssertAuthorizations)
                {
                    _validator.AssertAuthorizations(contextUser, this.AppContext, this);
                }

                if (_validator.CanValidate)
                {
                    result = _validator.Validate(contextUser, this.AppContext, this, errors);
                }
                else
                {
                    result = true;
                }
            }
            else
            {
                result = true;
            }

            return(result);
        }
        public IDomainTree Load(EntityData entityData)
        {
            var outcome = _validator.Validate(entityData);

            if (outcome.IsFailure)
            {
                throw new DataValidationException(outcome.Message);
            }

            IDomainTree domainTree = new DomainTree();

            var domainAttributesCount = entityData.Attributes.Count;

            var attributesBuffer = new string[domainAttributesCount];

            entityData.Attributes.CopyTo(attributesBuffer);
            domainTree.Attributes = new List <string>(attributesBuffer);

            for (var i = 0; i < domainAttributesCount; i++)
            {
                domainTree.Domain.Add(new List <string>());
            }

            EvalInputFrom(entityData, domainTree);

            return(domainTree);
        }