u4-9322 - events cleanup

This commit is contained in:
Stephan
2017-01-20 17:05:22 +01:00
parent 20ac21aef2
commit 1701eb2450
5 changed files with 13 additions and 15 deletions

View File

@@ -19,14 +19,14 @@ namespace Umbraco.Core.Events
}
public void TrackEvent<TSender, TEventArgs>(TypedEventHandler<TSender, TEventArgs> e, TSender sender, TEventArgs args)
{
{
_tracked.Add(new EventDefinition<TSender, TEventArgs>(e, sender, args));
}
public IEnumerable<IEventDefinition> GetEvents()
{
return _tracked;
}
}
private readonly List<EventDefinitionBase> _tracked = new List<EventDefinitionBase>();
@@ -39,7 +39,5 @@ namespace Umbraco.Core.Events
{
_tracked.Clear();
}
}
}

View File

@@ -17,7 +17,7 @@ namespace Umbraco.Core.Persistence.Repositories
{
private readonly ICacheProvider _globalCache;
public ServerRegistrationRepository(IDatabaseUnitOfWork work, ICacheProvider staticCache, ILogger logger, ISqlSyntaxProvider sqlSyntax)
public ServerRegistrationRepository(IScopeUnitOfWork work, ICacheProvider globalCache, ILogger logger, ISqlSyntaxProvider sqlSyntax)
: base(work, CacheHelper.NoCache, logger, sqlSyntax)
{
// managing the cache our own way (no policy etc)

View File

@@ -158,7 +158,7 @@ namespace Umbraco.Core.Persistence.UnitOfWork
public IEventManager EventManager
{
get { return ThisScope.EventManager; }
get { return Scope.Events; }
}
#region Operation

View File

@@ -79,7 +79,7 @@ namespace Umbraco.Core.Scoping
}
/// <inheritdoc />
public IEventManager EventManager
public IEventManager Events
{
get
{

View File

@@ -17,7 +17,7 @@ namespace Umbraco.Tests.Scoping
public void Does_Support_Event_Cancellation()
{
var scopeProvider = new ScopeProvider(Mock.Of<IDatabaseFactory2>());
Assert.IsTrue(scopeProvider.AmbientOrNoScope.EventManager.SupportsEventCancellation);
Assert.IsTrue(scopeProvider.AmbientOrNoScope.Events.SupportsEventCancellation);
}
[Test]
@@ -41,9 +41,9 @@ namespace Umbraco.Tests.Scoping
};
var scopeProvider = new ScopeProvider(Mock.Of<IDatabaseFactory2>());
scopeProvider.AmbientOrNoScope.EventManager.TrackEvent(DoThing1, this, new EventArgs());
scopeProvider.AmbientOrNoScope.EventManager.TrackEvent(DoThing2, this, new EventArgs());
scopeProvider.AmbientOrNoScope.EventManager.TrackEvent(DoThing3, this, new EventArgs());
scopeProvider.AmbientOrNoScope.Events.TrackEvent(DoThing1, this, new EventArgs());
scopeProvider.AmbientOrNoScope.Events.TrackEvent(DoThing2, this, new EventArgs());
scopeProvider.AmbientOrNoScope.Events.TrackEvent(DoThing3, this, new EventArgs());
Assert.AreEqual(3, counter);
@@ -53,11 +53,11 @@ namespace Umbraco.Tests.Scoping
public void Can_Not_Raise_Events_Later()
{
var scopeProvider = new ScopeProvider(Mock.Of<IDatabaseFactory2>());
scopeProvider.AmbientOrNoScope.EventManager.TrackEvent(DoThing1, this, new EventArgs());
scopeProvider.AmbientOrNoScope.EventManager.TrackEvent(DoThing2, this, new EventArgs());
scopeProvider.AmbientOrNoScope.EventManager.TrackEvent(DoThing3, this, new EventArgs());
scopeProvider.AmbientOrNoScope.Events.TrackEvent(DoThing1, this, new EventArgs());
scopeProvider.AmbientOrNoScope.Events.TrackEvent(DoThing2, this, new EventArgs());
scopeProvider.AmbientOrNoScope.Events.TrackEvent(DoThing3, this, new EventArgs());
Assert.AreEqual(0, scopeProvider.AmbientOrNoScope.EventManager.GetEvents().Count());
Assert.AreEqual(0, scopeProvider.AmbientOrNoScope.Events.GetEvents().Count());
}
public event EventHandler DoThing1;