Renamed Umbraco.Abstractions to Umbraco.Core
This commit is contained in:
39
src/Umbraco.Core/Composing/ComponentCollectionBuilder.cs
Normal file
39
src/Umbraco.Core/Composing/ComponentCollectionBuilder.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Umbraco.Core.Logging;
|
||||
|
||||
namespace Umbraco.Core.Composing
|
||||
{
|
||||
/// <summary>
|
||||
/// Builds a <see cref="ComponentCollection"/>.
|
||||
/// </summary>
|
||||
public class ComponentCollectionBuilder : OrderedCollectionBuilderBase<ComponentCollectionBuilder, ComponentCollection, IComponent>
|
||||
{
|
||||
private const int LogThresholdMilliseconds = 100;
|
||||
|
||||
private IProfilingLogger _logger;
|
||||
|
||||
public ComponentCollectionBuilder()
|
||||
{ }
|
||||
|
||||
protected override ComponentCollectionBuilder This => this;
|
||||
|
||||
protected override IEnumerable<IComponent> CreateItems(IFactory factory)
|
||||
{
|
||||
_logger = factory.GetInstance<IProfilingLogger>();
|
||||
|
||||
using (_logger.DebugDuration<ComponentCollectionBuilder>($"Creating components. (log when >{LogThresholdMilliseconds}ms)", "Created."))
|
||||
{
|
||||
return base.CreateItems(factory);
|
||||
}
|
||||
}
|
||||
|
||||
protected override IComponent CreateItem(IFactory factory, Type itemType)
|
||||
{
|
||||
using (_logger.DebugDuration<ComponentCollectionBuilder>($"Creating {itemType.FullName}.", $"Created {itemType.FullName}.", thresholdMilliseconds: LogThresholdMilliseconds))
|
||||
{
|
||||
return base.CreateItem(factory, itemType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user