using System; using System.Collections.Generic; using Umbraco.Core.Logging; namespace Umbraco.Core.Composing { /// /// Builds a . /// public class ComponentCollectionBuilder : OrderedCollectionBuilderBase { private const int LogThresholdMilliseconds = 100; private IProfilingLogger _logger; public ComponentCollectionBuilder() { } protected override ComponentCollectionBuilder This => this; protected override IEnumerable CreateItems(IFactory factory) { _logger = factory.GetInstance(); using (_logger.DebugDuration($"Creating components. (log when >{LogThresholdMilliseconds}ms)", "Created.")) { return base.CreateItems(factory); } } protected override IComponent CreateItem(IFactory factory, Type itemType) { using (_logger.DebugDuration($"Creating {itemType.FullName}.", $"Created {itemType.FullName}.", thresholdMilliseconds: LogThresholdMilliseconds)) { return base.CreateItem(factory, itemType); } } } }