public IEnumerable <uSyncDependency> GetDependencies(IContent item, DependencyFlags flags) { uSyncDependency.FireUpdate(item.Name); var dependencies = new List <uSyncDependency>(); dependencies.Add(new uSyncDependency() { Name = item.Name, Udi = item.GetUdi(), Order = DependencyOrders.Content, Flags = flags, Level = item.Level }); if (flags.HasFlag(DependencyFlags.IncludeDependencies)) { var contentType = CalcDocTypeDependency(item, flags); if (contentType != null) { dependencies.Add(contentType); } } // if we are getting linked items or media, include in the look up. if (flags.HasFlagAny(DependencyFlags.IncludeLinked | DependencyFlags.IncludeMedia | DependencyFlags.IncludeDependencies)) { uSyncDependency.FireUpdate($"{item.Name} Property Dependencies"); dependencies.AddRange(GetPropertyDependencies(item, flags)); } if (flags.HasFlag(DependencyFlags.IncludeAncestors)) { uSyncDependency.FireUpdate($"{item.Name} Ancestors"); dependencies.AddRange(GetParentDependencies(item.Id, DependencyOrders.Content - 1, flags)); } if (flags.HasFlag(DependencyFlags.IncludeChildren)) { uSyncDependency.FireUpdate($"{item.Name} Children"); dependencies.AddRange(GetChildDepencies(item.Id, DependencyOrders.Content + 1, flags, 1, uSyncContent.DependencyCountMax)); } return(dependencies); }
protected IEnumerable <uSyncDependency> GetChildDepencies(int id, int order, DependencyFlags flags, int min, int max) { var children = entityService.GetChildren(id).ToList(); if (children.Count == 0) { return(Enumerable.Empty <uSyncDependency>()); } var dependencies = new List <uSyncDependency>(); var step = (max - min) / children.Count; foreach (var item in children.Select((Child, Index) => new { Child, Index })) { var stepCount = min + item.Index * step; uSyncDependency.FireUpdate($"Child Content : {item.Child.Name}", stepCount, uSyncContent.DependencyCountMax); dependencies.Add(new uSyncDependency() { Name = item.Child.Name, Udi = Udi.Create(this.ObjectType.GetUdiType(), item.Child.Key), Order = order, Flags = flags & ~DependencyFlags.IncludeAncestors, Level = item.Child.Level }); if (flags.HasFlagAny(DependencyFlags.IncludeLinked | DependencyFlags.IncludeMedia)) { var contentChild = GetItemById(item.Child.Id); dependencies.AddRange(GetPropertyDependencies(contentChild, flags)); } dependencies.AddRange(GetChildDepencies(item.Child.Id, order + 1, flags, stepCount, stepCount + step)); } return(dependencies); }