Adds in Composition Extension Methods to allow Setting the LogViewer without having to know the composition.RegisterUnique syntax
This commit is contained in:
@@ -10,6 +10,7 @@ using Umbraco.Core.PropertyEditors;
|
|||||||
using Umbraco.Core.Strings;
|
using Umbraco.Core.Strings;
|
||||||
using Umbraco.Core.Sync;
|
using Umbraco.Core.Sync;
|
||||||
using Umbraco.Core._Legacy.PackageActions;
|
using Umbraco.Core._Legacy.PackageActions;
|
||||||
|
using Umbraco.Core.Logging.Viewer;
|
||||||
|
|
||||||
namespace Umbraco.Core.Components
|
namespace Umbraco.Core.Components
|
||||||
{
|
{
|
||||||
@@ -297,6 +298,37 @@ namespace Umbraco.Core.Components
|
|||||||
public static void SetMediaFileSystem(this Composition composition, Func<IFileSystem> filesystemFactory)
|
public static void SetMediaFileSystem(this Composition composition, Func<IFileSystem> filesystemFactory)
|
||||||
=> composition.RegisterUniqueFor<IFileSystem, IMediaFileSystem>(_ => filesystemFactory());
|
=> composition.RegisterUniqueFor<IFileSystem, IMediaFileSystem>(_ => filesystemFactory());
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the log viewer.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">The type of the log viewer.</typeparam>
|
||||||
|
/// <param name="composition">The composition.</param>
|
||||||
|
public static void SetLogViewer<T>(this Composition composition)
|
||||||
|
where T : ILogViewer
|
||||||
|
{
|
||||||
|
composition.RegisterUnique<ILogViewer, T>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the log viewer.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="composition">The composition.</param>
|
||||||
|
/// <param name="factory">A function creating a log viewer.</param>
|
||||||
|
public static void SetLogViewer(this Composition composition, Func<IFactory, ILogViewer> factory)
|
||||||
|
{
|
||||||
|
composition.RegisterUnique(factory);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the log viewer.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="composition">A composition.</param>
|
||||||
|
/// <param name="helper">A log viewer.</param>
|
||||||
|
public static void SetLogViewer(this Composition composition, ILogViewer viewer)
|
||||||
|
{
|
||||||
|
composition.RegisterUnique(_ => viewer);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ namespace Umbraco.Core.Logging.Viewer
|
|||||||
{
|
{
|
||||||
public void Compose(Composition composition)
|
public void Compose(Composition composition)
|
||||||
{
|
{
|
||||||
composition.RegisterUnique<ILogViewer>(_ => new JsonLogViewer());
|
composition.SetLogViewer(_ => new JsonLogViewer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user