Esempio n. 1
0
        private static Regex GetChildPathRegex(IModelObject node, ChildPropertyInfo childProperty)
        {
            var path = node.GetFolderPath();

            return(string.IsNullOrEmpty(path) ?
                   new Regex($@"{childProperty.FolderName}/[\w-]+/{FileSystemStorage.DataFile}", RegexOptions.IgnoreCase) :
                   new Regex($@"{path}/{childProperty.FolderName}/[\w-]+/{FileSystemStorage.DataFile}", RegexOptions.IgnoreCase));
        }
 ILazyChildren LoadEntryChildren(ObjectId commitId, string path, ChildPropertyInfo childProperty) =>
 LazyChildrenHelper.Create(childProperty, (parent, repository) =>
 {
     var childPath = string.IsNullOrEmpty(path) ? childProperty.Name : $"{path}/{childProperty.Name}";
     var commit    = repository.Lookup <Commit>(commitId);
     var subTree   = (Tree)commit[childPath]?.Target;
     return((subTree?.Any() ?? false) ?
            LoadEntryChildren(commitId, childPath, subTree) :
            Enumerable.Empty <IMetadataObject>());
 });
Esempio n. 3
0
        /// <summary>
        /// Creates a new instance of <see cref="ILazyChildren"/> for a <see cref="ChildPropertyInfo"/>.
        /// </summary>
        /// <param name="propertyInfo">The property information.</param>
        /// <param name="factory">The factory.</param>
        /// <returns>The new lazy children instance.</returns>
        internal static ILazyChildren Create(ChildPropertyInfo propertyInfo, Func <IModelObject, IRepository, IEnumerable <IModelObject> > factory)
        {
            var targetType = typeof(LazyChildren <>).MakeGenericType(propertyInfo.ItemType);

            return((ILazyChildren)Activator.CreateInstance(targetType, factory));
        }
Esempio n. 4
0
 /// <summary>
 /// Creates a nested context.
 /// </summary>
 /// <param name="property">The property.</param>
 /// <param name="instance">The instance.</param>
 /// <returns>The new context.</returns>
 public ValidationContext NewNested(ChildPropertyInfo property, IModelObject instance)
 {
     return(new ValidationContext(instance, Chain.Add(Instance, property), Rules, this));
 }
Esempio n. 5
0
 private void CompareNodeChildren(IModelObject original, IModelObject @new, IList <ObjectRepositoryEntryChanges> changes, Stack <string> stack, ChildPropertyInfo childProperty)
 {
     using (var enumerator = new TwoSequenceEnumerator <IModelObject>(
                childProperty.Accessor(original),
                childProperty.Accessor(@new)))
     {
         while (!enumerator.BothCompleted)
         {
             CompareNodeChildren(changes, stack, enumerator);
         }
     }
 }
 private ILazyChildren LoadEntryChildren(IObjectRepositoryContainer container, ObjectId commitId, string path, ChildPropertyInfo childProperty) =>
 LazyChildrenHelper.Create(childProperty, (parent, repository) =>
 {
     var childPath = string.IsNullOrEmpty(path) ? childProperty.FolderName : $"{path}/{childProperty.FolderName}";
     var commit    = repository.Lookup <Commit>(commitId);
     var entry     = commit[childPath];
     if (entry == null)
     {
         return(Enumerable.Empty <IModelObject>());
     }
     var subTree = (Tree)entry.Target;
     return(subTree.Any() ?
            LoadEntryChildren(container, commitId, childPath, subTree) :
            Enumerable.Empty <IModelObject>());
 });