protected override void AssignChildObjects() // abstract { foreach (TermGroup clientTermGroup in this.ClientObject.Groups.ToList()) { if (clientTermGroup.IsSiteCollectionGroup || clientTermGroup.IsSystemGroup) { continue; } if (!this.Options.MatchesGroupIdFilter(clientTermGroup.Id)) { continue; } var stopwatch = new Stopwatch(); stopwatch.Start(); // Copy the clientTermGroup into a new LocalTermGroup var termGroupDownloader = new TermGroupDownloader(this.DownloaderContext, clientTermGroup, this.TreeDepth + 1); termGroupDownloader.AssignMinimalProperties(); LocalTermGroup termGroup = termGroupDownloader.LocalObject; // Add the LocalTermGroup to the LocalTermStore this.LocalObject.AddTermGroup(termGroup); if (this.ShouldRecurse) { Debug.WriteLine("==> Fetching children for Group: " + termGroup.Name); // Fetch the rest of the tree termGroupDownloader.FetchItem(); } Debug.WriteLine("TOTAL TIME FOR Group" + termGroup.Name + ": " + stopwatch.ElapsedMilliseconds + " ms"); } }
protected override void QueryChildObjects() // abstract { var childRetrievals = TermGroupDownloader.GetRetrievalsForMinimalProperties(); if (this.Options.GroupIdFilter != null) { // Load only groups appearing on the whitelist // "termGroup => termGroup.Id == guid1 || termGroup.Id == guid2 || termGroup.Id == guid3" Expression predicateBody = null; var termGroupParameter = Expression.Parameter(typeof(TermGroup), "termGroup"); foreach (var guid in this.Options.GroupIdFilter) { Expression comparison = Expression.Equal( Expression.Property(termGroupParameter, "Id"), Expression.Constant(guid) ); if (predicateBody == null) { predicateBody = comparison; } else { predicateBody = Expression.OrElse(predicateBody, comparison); } } var wherePredicate = Expression.Lambda <Func <TermGroup, bool> >( predicateBody, new ParameterExpression[] { termGroupParameter } ); // "termStore => termStore.Groups.Where(wherePredicate).Include(childRetrievals)" var termStoreParameter = Expression.Parameter(typeof(TermStore), "termStore"); var retrieval = Expression.Lambda <Func <TermStore, object> >( Expression.Call(typeof(ClientObjectQueryableExtension), "Include", new Type[] { typeof(TermGroup) }, new Expression[] { Expression.Call(typeof(Queryable), "Where", new Type[] { typeof(TermGroup) }, new Expression[] { Expression.Property(termStoreParameter, "Groups"), wherePredicate } ), Expression.Constant(childRetrievals) } ), new ParameterExpression[] { termStoreParameter } ); this.ClientContext.Load(this.ClientTermStore, retrieval); } else { // Load all groups this.ClientContext.Load(this.ClientTermStore, termStore => termStore.Groups.Include(childRetrievals)); } }
protected override void QueryMinimalProperties() { this.ClientContext.Load(this.ClientTermGroup, TermGroupDownloader.GetRetrievalsForMinimalProperties()); }