Files
Umbraco-CMS/src/Umbraco.Web/ContentApps/ContentAppFactoryCollectionBuilder.cs

36 lines
1.5 KiB
C#
Raw Normal View History

using System.Collections.Generic;
using System.Linq;
2019-02-14 09:15:47 +01:00
using Umbraco.Core;
using Umbraco.Core.Composing;
2019-11-08 10:57:24 +01:00
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.Manifest;
using Umbraco.Core.Models.ContentEditing;
namespace Umbraco.Web.ContentApps
{
2018-12-07 14:05:47 +01:00
public class ContentAppFactoryCollectionBuilder : OrderedCollectionBuilderBase<ContentAppFactoryCollectionBuilder, ContentAppFactoryCollection, IContentAppFactory>
{
2018-12-07 14:05:47 +01:00
protected override ContentAppFactoryCollectionBuilder This => this;
// need to inject dependencies in the collection, so override creation
2018-12-07 16:12:08 +01:00
public override ContentAppFactoryCollection CreateCollection(IFactory factory)
{
// get the logger just-in-time - see note below for manifest parser
2018-11-28 11:05:41 +01:00
var logger = factory.GetInstance<ILogger>();
2018-12-07 16:12:08 +01:00
return new ContentAppFactoryCollection(CreateItems(factory), logger);
}
2018-12-07 16:12:08 +01:00
protected override IEnumerable<IContentAppFactory> CreateItems(IFactory factory)
{
2018-09-20 18:51:46 +02: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
2019-11-06 13:35:34 +01:00
var manifestParser = factory.GetInstance<IManifestParser>();
2018-09-20 18:51:46 +02:00
2019-11-08 10:57:24 +01:00
return base.CreateItems(factory).Concat(manifestParser.Manifest.ContentApps.Select(x => new ManifestContentAppFactory(x, Current.IOHelper)));
}
}
}