Removes ctor's accepting delegates and instead makes them abstract methods, adds some docs

This commit is contained in:
Shannon
2015-03-27 10:25:25 +11:00
parent e001ed93c1
commit c73749ea54
5 changed files with 49 additions and 44 deletions

View File

@@ -4,38 +4,44 @@ using Umbraco.Core.Sync;
namespace Umbraco.Web
{
/// <summary>
/// An <see cref="IServerMessenger"/> that works by messaging servers via web services.
/// </summary>
/// <remarks>
/// This binds to appropriate umbraco events in order to trigger the FlushBatch() calls
/// </remarks>
internal class BatchedWebServiceServerMessenger : Core.Sync.BatchedWebServiceServerMessenger
{
internal BatchedWebServiceServerMessenger()
: base(GetBatch)
: base()
{
UmbracoModule.EndRequest += UmbracoModule_EndRequest;
}
internal BatchedWebServiceServerMessenger(string login, string password)
: base(login, password, GetBatch)
: base(login, password)
{
UmbracoModule.EndRequest += UmbracoModule_EndRequest;
}
internal BatchedWebServiceServerMessenger(string login, string password, bool useDistributedCalls)
: base(login, password, useDistributedCalls, GetBatch)
: base(login, password, useDistributedCalls)
{
UmbracoModule.EndRequest += UmbracoModule_EndRequest;
}
public BatchedWebServiceServerMessenger(Func<Tuple<string, string>> getLoginAndPassword)
: base(getLoginAndPassword, GetBatch)
: base(getLoginAndPassword)
{
UmbracoModule.EndRequest += UmbracoModule_EndRequest;
}
private static ICollection<RefreshInstructionEnvelope> GetBatch(bool ensure)
protected override ICollection<RefreshInstructionEnvelope> GetBatch(bool ensureHttpContext)
{
var httpContext = UmbracoContext.Current == null ? null : UmbracoContext.Current.HttpContext;
if (httpContext == null)
{
if (ensure)
if (ensureHttpContext)
throw new NotSupportedException("Cannot execute without a valid/current UmbracoContext with an HttpContext assigned.");
return null;
}
@@ -44,7 +50,7 @@ namespace Umbraco.Web
// no thread-safety here because it'll run in only 1 thread (request) at a time
var batch = (ICollection<RefreshInstructionEnvelope>)httpContext.Items[key];
if (batch == null && ensure)
if (batch == null && ensureHttpContext)
httpContext.Items[key] = batch = new List<RefreshInstructionEnvelope>();
return batch;
}