diff --git a/src/Umbraco.Core/Components/CompositionExtensions.cs b/src/Umbraco.Core/Components/CompositionExtensions.cs
index a4bc82cb4b..bb23e89b81 100644
--- a/src/Umbraco.Core/Components/CompositionExtensions.cs
+++ b/src/Umbraco.Core/Components/CompositionExtensions.cs
@@ -281,6 +281,22 @@ namespace Umbraco.Core.Components
composition.RegisterUnique(_ => helper);
}
+ ///
+ /// Sets the underlying media filesystem.
+ ///
+ /// A composition.
+ /// A filesystem factory.
+ public static void SetMediaFileSystem(this Composition composition, Func filesystemFactory)
+ => composition.RegisterUniqueFor(filesystemFactory);
+
+ ///
+ /// Sets the underlying media filesystem.
+ ///
+ /// A composition.
+ /// A filesystem factory.
+ public static void SetMediaFileSystem(this Composition composition, Func filesystemFactory)
+ => composition.RegisterUniqueFor(_ => filesystemFactory());
+
#endregion
}
}
diff --git a/src/Umbraco.Core/Composing/Composers/FileSystemsComposer.cs b/src/Umbraco.Core/Composing/Composers/FileSystemsComposer.cs
index ab4bd015de..4c598f27e4 100644
--- a/src/Umbraco.Core/Composing/Composers/FileSystemsComposer.cs
+++ b/src/Umbraco.Core/Composing/Composers/FileSystemsComposer.cs
@@ -88,9 +88,9 @@ namespace Umbraco.Core.Composing.Composers
composition.Register(factory => new SupportingFileSystems(factory), Lifetime.Singleton);
// register the IFileSystem supporting the IMediaFileSystem
- // this is the only thing that need to be overriden to change the supporting filesystem
+ // THIS IS THE ONLY THING THAT NEEDS TO CHANGE, IN ORDER TO REPLACE THE UNDERLYING FILESYSTEM
// and, SupportingFileSystem.For() returns the underlying filesystem
- composition.RegisterUniqueFor(_ => new PhysicalFileSystem("~/media"));
+ composition.SetMediaFileSystem(() => new PhysicalFileSystem("~/media"));
return composition;
}
diff --git a/src/Umbraco.Core/Composing/IRegister.cs b/src/Umbraco.Core/Composing/IRegister.cs
index 3e6aed67ee..cbf12f54a3 100644
--- a/src/Umbraco.Core/Composing/IRegister.cs
+++ b/src/Umbraco.Core/Composing/IRegister.cs
@@ -36,24 +36,40 @@ namespace Umbraco.Core.Composing
///
/// Registers a service for a target, as its own implementation.
///
+ ///
+ /// There can only be one implementation or instanced registered for a service and target;
+ /// what happens if many are registered is not specified.
+ ///
void RegisterFor(Lifetime lifetime = Lifetime.Transient)
where TService : class;
///
/// Registers a service for a target, with an implementation type.
///
+ ///
+ /// There can only be one implementation or instanced registered for a service and target;
+ /// what happens if many are registered is not specified.
+ ///
void RegisterFor(Type implementingType, Lifetime lifetime = Lifetime.Transient)
where TService : class;
///
/// Registers a service for a target, with an implementation factory.
///
+ ///
+ /// There can only be one implementation or instanced registered for a service and target;
+ /// what happens if many are registered is not specified.
+ ///
void RegisterFor(Func factory, Lifetime lifetime = Lifetime.Transient)
where TService : class;
///
/// Registers a service for a target, with an implementing instance.
///
+ ///
+ /// There can only be one implementation or instanced registered for a service and target;
+ /// what happens if many are registered is not specified.
+ ///
void RegisterFor(TService instance)
where TService : class;