Пример #1
0
        IMetadataObject DeepClone(IMetadataObject node, ProcessArgument processArgument, ChildChangesGetter childChangesGetter, Func <IMetadataObject, bool> mustForceVisit)
        {
            if (node == null)
            {
                throw new ArgumentNullException(nameof(node));
            }
            if (processArgument == null)
            {
                throw new ArgumentNullException(nameof(processArgument));
            }
            if (childChangesGetter == null)
            {
                throw new ArgumentNullException(nameof(childChangesGetter));
            }
            if (mustForceVisit == null)
            {
                throw new ArgumentNullException(nameof(mustForceVisit));
            }

            ILazyChildren ProcessChildren(ChildPropertyInfo childProperty, ILazyChildren children, IMetadataObject @new, IModelDataAccessor childDataAccessor)
            {
                var childChanges = childChangesGetter.Invoke(node, childProperty);

                return(children.Clone(
                           forceVisit: mustForceVisit(children.Parent),
                           update: n => DeepClone(n, processArgument, childChangesGetter, mustForceVisit),
                           added: childChanges.Additions,
                           deleted: childChanges.Deletions));
            }

            return(node.DataAccessor.ConstructorParameterBinding.Cloner(node, processArgument, ProcessChildren));
        }
Пример #2
0
        /// <inheritdoc />
        public IObjectRepository DeepClone(IObjectRepository instance, ProcessArgument processArgument, ChildChangesGetter childChangesGetter, Func <IMetadataObject, bool> mustForceVisit)
        {
            if (instance == null)
            {
                throw new ArgumentNullException(nameof(instance));
            }

            return((IObjectRepository)DeepClone((IMetadataObject)instance, processArgument, childChangesGetter, mustForceVisit));
        }