Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugfix exception during install, live models collision
- Loading branch information
Stephan
committed
Feb 22, 2019
1 parent
04e916b
commit aa86dfa
Showing
9 changed files
with
58 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System; | ||
using Umbraco.Core.Models.PublishedContent; | ||
|
||
namespace Umbraco.Core | ||
{ | ||
/// <summary> | ||
/// Provides extension methods for <see cref="IPublishedModelFactory"/>. | ||
/// </summary> | ||
public static class PublishedModelFactoryExtensions | ||
{ | ||
/// <summary> | ||
/// Executes an action with a safe live factory/ | ||
/// </summary> | ||
/// <remarks> | ||
/// <para>If the factory is a live factory, ensures it is refreshed and locked while executing the action.</para> | ||
/// </remarks> | ||
public static void WithSafeLiveFactory(this IPublishedModelFactory factory, Action action) | ||
{ | ||
if (factory is ILivePublishedModelFactory liveFactory) | ||
{ | ||
lock (liveFactory.SyncRoot) | ||
{ | ||
liveFactory.Refresh(); | ||
action(); | ||
} | ||
} | ||
else | ||
{ | ||
action(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters