Merge remote-tracking branch 'origin/v8/dev' into netcore/dev
# Conflicts: # src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs # src/Umbraco.Core/PublishedCache/PublishedSnapshotServiceBase.cs # src/Umbraco.Core/PublishedModelFactoryExtensions.cs # src/Umbraco.Web.UI.Client/package-lock.json # src/Umbraco.Web.UI.Client/src/views/propertyeditors/imagecropper/imagecropper.controller.js # src/Umbraco.Web.UI.Client/src/views/users/user.controller.js # src/Umbraco.Web.UI/Umbraco/Views/Default.cshtml
This commit is contained in:
@@ -17,6 +17,39 @@ namespace Umbraco.Core
|
||||
/// <returns></returns>
|
||||
public static bool IsLiveFactory(this IPublishedModelFactory factory) => factory is ILivePublishedModelFactory;
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the current <see cref="IPublishedModelFactory"/> is an implementation of <see cref="ILivePublishedModelFactory2"/> and is enabled
|
||||
/// </summary>
|
||||
/// <param name="factory"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsLiveFactoryEnabled(this IPublishedModelFactory factory)
|
||||
{
|
||||
if (factory is ILivePublishedModelFactory liveFactory)
|
||||
return liveFactory.Enabled;
|
||||
|
||||
// if it's not ILivePublishedModelFactory we can't determine if it's enabled or not so return true
|
||||
return true;
|
||||
}
|
||||
|
||||
[Obsolete("This method is no longer used or necessary and will be removed from future")]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public static void WithSafeLiveFactory(this IPublishedModelFactory factory, Action action)
|
||||
{
|
||||
if (factory is ILivePublishedModelFactory liveFactory)
|
||||
{
|
||||
lock (liveFactory.SyncRoot)
|
||||
{
|
||||
//Call refresh on the live factory to re-compile the models
|
||||
liveFactory.Refresh();
|
||||
action();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
action();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a flag to reset the ModelsBuilder models if the <see cref="IPublishedModelFactory"/> is <see cref="ILivePublishedModelFactory"/>
|
||||
/// </summary>
|
||||
@@ -31,14 +64,7 @@ namespace Umbraco.Core
|
||||
{
|
||||
lock (liveFactory.SyncRoot)
|
||||
{
|
||||
// TODO: Fix this in 8.3! - We need to change the ILivePublishedModelFactory interface to have a Reset method and then when we have an embedded MB
|
||||
// version we will publicize the ResetModels (and change the name to Reset).
|
||||
// For now, this will suffice and we'll use reflection, there should be no other implementation of ILivePublishedModelFactory.
|
||||
// Calling ResetModels resets the MB flag so that the next time EnsureModels is called (which is called when nucache lazily calls CreateModel) it will
|
||||
// trigger the recompiling of pure live models.
|
||||
var resetMethod = liveFactory.GetType().GetMethod("ResetModels", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
|
||||
if (resetMethod != null)
|
||||
resetMethod.Invoke(liveFactory, null);
|
||||
liveFactory.Reset();
|
||||
|
||||
action();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user