diff --git a/src/Umbraco.Core/Scoping/NoScope.cs b/src/Umbraco.Core/Scoping/NoScope.cs
index e1a62724e3..756a2dfdc0 100644
--- a/src/Umbraco.Core/Scoping/NoScope.cs
+++ b/src/Umbraco.Core/Scoping/NoScope.cs
@@ -14,8 +14,6 @@ namespace Umbraco.Core.Scoping
private bool _disposed;
private UmbracoDatabase _database;
- private IEventDispatcher _eventDispatcher;
- private EventMessages _messages;
public NoScope(ScopeProvider scopeProvider)
{
@@ -37,7 +35,7 @@ namespace Umbraco.Core.Scoping
}
///
- public IsolatedRuntimeCache IsolatedRuntimeCache { get { throw new NotImplementedException(); } }
+ public IsolatedRuntimeCache IsolatedRuntimeCache { get { throw new NotSupportedException(); } }
///
public UmbracoDatabase Database
@@ -61,55 +59,42 @@ namespace Umbraco.Core.Scoping
///
public EventMessages Messages
{
- get
- {
- EnsureNotDisposed();
- // fixme - should be a 'no scope event messages' of some sort
- return _messages ?? (_messages = new EventMessages());
- }
+ get { throw new NotSupportedException(); }
}
public EventMessages MessagesOrNull
{
- get
- {
- EnsureNotDisposed();
- return _messages;
- }
+ get { throw new NotSupportedException(); }
}
///
public IEventDispatcher Events
{
- get
- {
- EnsureNotDisposed();
- return _eventDispatcher ?? (_eventDispatcher = new PassThroughEventDispatcher());
- }
+ get { throw new NotSupportedException(); }
}
///
public void Complete()
{
- throw new NotImplementedException();
+ throw new NotSupportedException();
}
///
public T Enlist(string key, Func creator)
{
- throw new NotImplementedException();
+ throw new NotSupportedException();
}
///
public T Enlist(string key, Func creator, ActionTime actionTimes, Action action)
{
- throw new NotImplementedException();
+ throw new NotSupportedException();
}
///
public void Enlist(string key, ActionTime actionTimes, Action action)
{
- throw new NotImplementedException();
+ throw new NotSupportedException();
}
private void EnsureNotDisposed()
diff --git a/src/Umbraco.Core/Scoping/Scope.cs b/src/Umbraco.Core/Scoping/Scope.cs
index a43500cf83..9d4d794302 100644
--- a/src/Umbraco.Core/Scoping/Scope.cs
+++ b/src/Umbraco.Core/Scoping/Scope.cs
@@ -78,7 +78,6 @@ namespace Umbraco.Core.Scoping
{
// steal everything from NoScope
_database = noScope.DatabaseOrNull;
- _messages = noScope.MessagesOrNull;
// make sure the NoScope can be replaced ie not in a transaction
if (_database != null && _database.InTransaction)
@@ -203,7 +202,11 @@ namespace Umbraco.Core.Scoping
{
EnsureNotDisposed();
if (ParentScope != null) return ParentScope.Messages;
- return _messages ?? (_messages = new EventMessages());
+ //return _messages ?? (_messages = new EventMessages());
+
+ // ok, this isn't pretty, but it works
+ // TODO kill the message factory and let the scope manage it all
+ return ApplicationContext.Current.Services.EventMessagesFactory.Get();
}
}
diff --git a/src/Umbraco.Tests/Scoping/PassThroughEventDispatcherTests.cs b/src/Umbraco.Tests/Scoping/PassThroughEventDispatcherTests.cs
index a730d74630..6020d1f888 100644
--- a/src/Umbraco.Tests/Scoping/PassThroughEventDispatcherTests.cs
+++ b/src/Umbraco.Tests/Scoping/PassThroughEventDispatcherTests.cs
@@ -8,6 +8,7 @@ using Umbraco.Core.Scoping;
namespace Umbraco.Tests.Scoping
{
[TestFixture]
+ [NUnit.Framework.Ignore("Cannot dispatch events on NoScope!")]
public class PassThroughEventDispatcherTests
{
[Test]
diff --git a/src/Umbraco.Tests/Scoping/ScopeEventDispatcherTests.cs b/src/Umbraco.Tests/Scoping/ScopeEventDispatcherTests.cs
index 5c1d105a9a..23921182ad 100644
--- a/src/Umbraco.Tests/Scoping/ScopeEventDispatcherTests.cs
+++ b/src/Umbraco.Tests/Scoping/ScopeEventDispatcherTests.cs
@@ -94,7 +94,7 @@ namespace Umbraco.Tests.Scoping
[TestCase(true)]
[TestCase(false)]
- public void TriggerEvents(bool complete)
+ public void EventsDispatchmode_PassThrough(bool complete)
{
var counter = 0;
@@ -125,7 +125,7 @@ namespace Umbraco.Tests.Scoping
[TestCase(true)]
[TestCase(false)]
- public void QueueAndDiscardEvents(bool complete)
+ public void EventsDispatchMode_Passive(bool complete)
{
DoThing1 += OnDoThingFail;
DoThing2 += OnDoThingFail;
@@ -150,7 +150,7 @@ namespace Umbraco.Tests.Scoping
[TestCase(true)]
[TestCase(false)]
- public void QueueAndRaiseEvents(bool complete)
+ public void EventsDispatchMode_Scope(bool complete)
{
var counter = 0;
IScope ambientScope = null;
diff --git a/src/umbraco.datalayer/SqlHelper.cs b/src/umbraco.datalayer/SqlHelper.cs
index 10d1183abb..8eadd01d35 100644
--- a/src/umbraco.datalayer/SqlHelper.cs
+++ b/src/umbraco.datalayer/SqlHelper.cs
@@ -363,7 +363,7 @@ namespace umbraco.DataLayer
//private static MethodInfo CloseMethod { get; set; }
private static readonly object ScopeProvider;
- private static readonly PropertyInfo ScopeProviderAmbientOrNoScopeProperty;
+ private static readonly MethodInfo ScopeProviderAmbientOrNoScopeMethod;
private static readonly PropertyInfo ScopeDatabaseProperty;
private static readonly PropertyInfo ConnectionProperty;
private static readonly FieldInfo TransactionField;
@@ -396,8 +396,8 @@ namespace umbraco.DataLayer
if (databaseContextScopeProviderField == null) throw new Exception("oops: databaseContextScopeProviderField.");
ScopeProvider = databaseContextScopeProviderField.GetValue(databaseContext);
- ScopeProviderAmbientOrNoScopeProperty = scopeProviderType.GetProperty("AmbientOrNoScope", BindingFlags.Instance | BindingFlags.Public);
- if (ScopeProviderAmbientOrNoScopeProperty == null) throw new Exception("oops: ScopeProviderAmbientOrNoScopeProperty.");
+ ScopeProviderAmbientOrNoScopeMethod = scopeProviderType.GetMethod("GetAmbientOrNoScope", BindingFlags.Instance | BindingFlags.Public);
+ if (ScopeProviderAmbientOrNoScopeMethod == null) throw new Exception("oops: ScopeProviderAmbientOrNoScopeMethod.");
ScopeDatabaseProperty = scopeType.GetProperty("Database", BindingFlags.Instance | BindingFlags.Public);
if (ScopeDatabaseProperty == null) throw new Exception("oops: ScopeDatabaseProperty.");
@@ -416,7 +416,7 @@ namespace umbraco.DataLayer
public CurrentConnectionUsing()
{
- var scope = ScopeProviderAmbientOrNoScopeProperty.GetValue(ScopeProvider);
+ var scope = ScopeProviderAmbientOrNoScopeMethod.Invoke(ScopeProvider, NoArgs);
_database = ScopeDatabaseProperty.GetValue(scope);
var connection = ConnectionProperty.GetValue(_database, NoArgs);