public override void Execute() { var root = repository.Get(host.CurrentSite.RootItemID); var discriminators = repository.FindDescendantDiscriminators(root).ToDictionary(d => d.Discriminator, d => d.Count); foreach (var definition in definitions.GetDefinitions()) { int numberOfItems; discriminators.TryGetValue(definition.Discriminator, out numberOfItems); definition.NumberOfItems = numberOfItems; } }
private void LoadSelectableTypes() { var discriminators = new HashSet <string>(repository .FindDescendantDiscriminators(Selection.SelectedItem) .Select(d => d.Discriminator)); ddlTypes.DataSource = Engine.Definitions.GetDefinitions() .Where(d => discriminators.Contains(d.Discriminator)) .OrderByDescending(d => typeof(ISystemNode).IsAssignableFrom(d.ItemType) ? 0 : 1) .ThenBy(d => d.IsPage ? 0 : 1) .ThenByDescending(d => d.NumberOfItems / 10) .ThenBy(d => d.SortOrder) .ThenBy(d => d.Title); ddlTypes.DataBind(); }