2020-10-30 11:16:17 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
2019-01-17 17:31:29 +11:00
|
|
|
|
using System.Linq;
|
2020-10-30 11:16:17 +00:00
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2021-02-18 11:06:02 +01:00
|
|
|
|
using Umbraco.Cms.Core.Composing;
|
|
|
|
|
|
using Umbraco.Cms.Core.Manifest;
|
2019-01-17 17:04:53 +11:00
|
|
|
|
|
2021-02-18 11:06:02 +01:00
|
|
|
|
namespace Umbraco.Cms.Core.Sections
|
2019-01-17 17:04:53 +11:00
|
|
|
|
{
|
2019-02-18 11:22:25 +01:00
|
|
|
|
public class SectionCollectionBuilder : OrderedCollectionBuilderBase<SectionCollectionBuilder, SectionCollection, ISection>
|
2019-01-17 17:04:53 +11:00
|
|
|
|
{
|
2019-02-18 11:22:25 +01:00
|
|
|
|
protected override SectionCollectionBuilder This => this;
|
2019-01-17 17:31:29 +11:00
|
|
|
|
|
2020-10-30 11:16:17 +00:00
|
|
|
|
protected override IEnumerable<ISection> CreateItems(IServiceProvider factory)
|
2019-01-17 17:31:29 +11:00
|
|
|
|
{
|
|
|
|
|
|
// get the manifest parser just-in-time - injecting it in the ctor would mean that
|
|
|
|
|
|
// simply getting the builder in order to configure the collection, would require
|
|
|
|
|
|
// its dependencies too, and that can create cycles or other oddities
|
2020-10-27 10:53:01 +00:00
|
|
|
|
var manifestParser = factory.GetRequiredService<IManifestParser>();
|
2019-01-17 17:31:29 +11:00
|
|
|
|
|
2021-07-15 13:26:32 -06:00
|
|
|
|
return base.CreateItems(factory).Concat(manifestParser.CombinedManifest.Sections);
|
2019-01-17 17:31:29 +11:00
|
|
|
|
}
|
2019-01-17 17:04:53 +11:00
|
|
|
|
}
|
|
|
|
|
|
}
|