コード例 #1
0
        /// <summary>
        /// Checks the current relations and prepares them for database serialization.
        /// </summary>
        public async Task ValidateAsync(Page page, string rawFacts)
        {
            var context = await RelationContext.LoadContextAsync(_db);

            AugmentRelationContext(context, page, rawFacts);

            var core = new ValidatorCore();

            core.Validate(context, new [] { page.Id });
            core.ThrowIfInvalid(context, nameof(PageEditorVM.Facts));
        }
コード例 #2
0
        /// <summary>
        /// Validates the context integrity.
        /// </summary>
        public async Task ValidateAsync(IReadOnlyList <Relation> relations)
        {
            var firstRel = relations?.FirstOrDefault();

            if (firstRel == null)
            {
                throw new ArgumentNullException();
            }

            var context = await RelationContext.LoadContextAsync(_db);

            foreach (var rel in relations)
            {
                context.Augment(CreateExcerpt(rel));
            }

            var core = new ValidatorCore();

            core.Validate(context, new [] { firstRel.SourceId, firstRel.DestinationId, firstRel.EventId ?? Guid.Empty });
            core.ThrowIfInvalid(context, nameof(RelationEditorVM.DestinationId));
        }