private static ChildPropertyInfo ExtractProperty(IModelDataAccessor dataAccessor, Expression propertyPicker)
        {
            if (propertyPicker == null)
            {
                throw new ArgumentNullException(nameof(propertyPicker));
            }

            var property = PropertyVisitor.ExtractProperty(propertyPicker);
            var result   = dataAccessor.ChildProperties.FirstOrDefault(p => p.Property == property);

            return(result ?? throw new GitObjectDbException($"Member should be a child property."));
        }
Exemple #2
0
        private void ValidateChildren(ValidationContext context, IModelDataAccessor dataProvider, List <ValidationFailure> result)
        {
            foreach (var childProperty in dataProvider.ChildProperties)
            {
                var children = childProperty.Accessor(context.Instance);
                if (children != null)
                {
                    foreach (var child in children)
                    {
                        var nestedContext = context.NewNested(childProperty, child);
                        ValidateImpl(nestedContext, result);
                    }
                }
            }

            ValidateContainer(context, result);
        }
Exemple #3
0
        private void ValidatePropertyValues(ValidationContext context, IModelDataAccessor dataProvider, List <ValidationFailure> result)
        {
            foreach (var property in dataProvider.ModifiableProperties)
            {
                var propertyValue = property.Accessor(context.Instance);
                if (propertyValue == null)
                {
                    continue;
                }

                if (property.IsDiscriminatedUnion)
                {
                    ValidateDiscriminatedUnion(context, property.Name, propertyValue, result);
                }
                else
                {
                    ValidatePropertyValue(context, property.Name, propertyValue, result);
                }
            }
        }
Exemple #4
0
 private static void UpdateNodeIfNeeded(IModelObject original, IModelObject @new, Stack <string> stack, IModelDataAccessor accessor, IList <ObjectRepositoryEntryChanges> changes)
 {
     if (accessor.ModifiableProperties.Any(p => !p.AreSame(original, @new)))
     {
         var path = stack.ToDataPath();
         changes.Add(new ObjectRepositoryEntryChanges(path, ChangeKind.Modified, original, @new));
     }
 }