2019-01-03 21:00:28 +01:00
|
|
|
|
using System.Collections.Generic;
|
2016-09-01 11:25:00 +02:00
|
|
|
|
using AutoMapper;
|
|
|
|
|
|
using Umbraco.Core.Components;
|
|
|
|
|
|
using Umbraco.Core.IO;
|
|
|
|
|
|
|
2017-12-28 09:27:57 +01:00
|
|
|
|
namespace Umbraco.Core.Runtime
|
2016-09-01 11:25:00 +02:00
|
|
|
|
{
|
2019-01-03 21:00:28 +01:00
|
|
|
|
public class CoreRuntimeComponent : IComponent
|
2016-09-01 11:25:00 +02:00
|
|
|
|
{
|
2019-01-07 09:30:47 +01:00
|
|
|
|
private readonly IEnumerable<Profile> _mapperProfiles;
|
|
|
|
|
|
|
2019-01-04 08:36:38 +01:00
|
|
|
|
public CoreRuntimeComponent(IEnumerable<Profile> mapperProfiles)
|
2019-01-07 09:30:47 +01:00
|
|
|
|
{
|
|
|
|
|
|
_mapperProfiles = mapperProfiles;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Initialize()
|
2016-09-01 11:25:00 +02:00
|
|
|
|
{
|
2017-07-19 13:42:47 +02:00
|
|
|
|
// mapper profiles have been registered & are created by the container
|
2016-09-01 11:25:00 +02:00
|
|
|
|
Mapper.Initialize(configuration =>
|
|
|
|
|
|
{
|
2019-01-07 09:30:47 +01:00
|
|
|
|
foreach (var profile in _mapperProfiles)
|
2017-07-19 13:42:47 +02:00
|
|
|
|
configuration.AddProfile(profile);
|
2016-09-01 11:25:00 +02:00
|
|
|
|
});
|
2016-09-08 18:43:58 +02:00
|
|
|
|
|
|
|
|
|
|
// ensure we have some essential directories
|
|
|
|
|
|
// every other component can then initialize safely
|
|
|
|
|
|
IOHelper.EnsurePathExists("~/App_Data");
|
|
|
|
|
|
IOHelper.EnsurePathExists(SystemDirectories.Media);
|
|
|
|
|
|
IOHelper.EnsurePathExists(SystemDirectories.MvcViews);
|
|
|
|
|
|
IOHelper.EnsurePathExists(SystemDirectories.MvcViews + "/Partials");
|
|
|
|
|
|
IOHelper.EnsurePathExists(SystemDirectories.MvcViews + "/MacroPartials");
|
2016-09-01 11:25:00 +02:00
|
|
|
|
}
|
2019-01-07 09:30:47 +01:00
|
|
|
|
|
|
|
|
|
|
public void Terminate()
|
|
|
|
|
|
{ }
|
2016-09-01 11:25:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|