Exemple #1
0
        /// <summary>
        /// Creates a copy of the repository and apply changes according to the new test values provided in the predicate.
        /// </summary>
        /// <typeparam name="TModel">The type of the model.</typeparam>
        /// <param name="source">The source.</param>
        /// <param name="predicate">The predicate.</param>
        /// <returns>The newly created copy. Both parents and children nodes have been cloned as well.</returns>
        public static TModel With <TModel>(this TModel source, IPredicateReflector predicate)
            where TModel : IMetadataObject
        {
            if (predicate == null)
            {
                throw new ArgumentNullException(nameof(predicate));
            }

            return((TModel)source.DataAccessor.With(source, predicate));
        }
        /// <inheritdoc />
        public IMetadataObject With(IMetadataObject source, IPredicateReflector predicate)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }
            if (predicate == null)
            {
                throw new ArgumentNullException(nameof(predicate));
            }

            var newInstance = DeepClone(
                source.Repository,
                predicate.ProcessArgument,
                predicate.GetChildChanges,
                n => n.IsParentOf(source));

            return(newInstance.TryGetFromGitPath(source.GetDataPath()));
        }