Resvolution - Components, Runtime & Booting
This commit is contained in:
@@ -138,7 +138,7 @@ namespace Umbraco.Web.UI.Controls
|
||||
|
||||
private bool DoesMacroHaveParameters(int macroId)
|
||||
{
|
||||
return ApplicationContext.DatabaseContext.Database.ExecuteScalar<int>(string.Format("SELECT COUNT(*) from cmsMacroProperty where macro = {0}", macroId)) > 0;
|
||||
return DatabaseContext.Database.ExecuteScalar<int>(string.Format("SELECT COUNT(*) from cmsMacroProperty where macro = {0}", macroId)) > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,9 @@ using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using System.Web.UI;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Services;
|
||||
using umbraco.BusinessLogic;
|
||||
using umbraco.DataLayer;
|
||||
|
||||
namespace Umbraco.Web.UI.Controls
|
||||
{
|
||||
@@ -16,73 +15,62 @@ namespace Umbraco.Web.UI.Controls
|
||||
/// </summary>
|
||||
public abstract class UmbracoControl : Control
|
||||
{
|
||||
private UrlHelper _url;
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
/// <param name="umbracoContext"></param>
|
||||
protected UmbracoControl(UmbracoContext umbracoContext)
|
||||
protected UmbracoControl(UmbracoContext umbracoContext, ServiceContext services, CacheHelper appCache)
|
||||
{
|
||||
if (umbracoContext == null) throw new ArgumentNullException("umbracoContext");
|
||||
if (umbracoContext == null) throw new ArgumentNullException(nameof(umbracoContext));
|
||||
UmbracoContext = umbracoContext;
|
||||
Umbraco = new UmbracoHelper(umbracoContext);
|
||||
Umbraco = new UmbracoHelper(umbracoContext, services, appCache);
|
||||
|
||||
// fixme inject somehow
|
||||
Logger = Current.Logger;
|
||||
ProfilingLogger = Current.ProfilingLogger;
|
||||
DatabaseContext = Current.DatabaseContext;
|
||||
Services = Current.Services;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Empty constructor, uses Singleton to resolve the UmbracoContext
|
||||
/// Empty constructor, uses Singleton to resolve the UmbracoContext.
|
||||
/// </summary>
|
||||
protected UmbracoControl()
|
||||
: this(UmbracoContext.Current)
|
||||
{
|
||||
}
|
||||
: this(Current.UmbracoContext, Current.Services, Current.ApplicationCache)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Returns an UmbracoHelper object
|
||||
/// </summary>
|
||||
public UmbracoHelper Umbraco { get; private set; }
|
||||
public UmbracoHelper Umbraco { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns an ILogger
|
||||
/// Gets the logger.
|
||||
/// </summary>
|
||||
public ILogger Logger
|
||||
{
|
||||
get { return ProfilingLogger.Logger; }
|
||||
}
|
||||
public ILogger Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the profiling logger.
|
||||
/// </summary>
|
||||
public ProfilingLogger ProfilingLogger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns a ProfilingLogger
|
||||
/// Gets the Umbraco context.
|
||||
/// </summary>
|
||||
public ProfilingLogger ProfilingLogger
|
||||
{
|
||||
get { return UmbracoContext.Application.ProfilingLogger; }
|
||||
}
|
||||
public UmbracoContext UmbracoContext { get; }
|
||||
|
||||
public UmbracoContext UmbracoContext { get; private set; }
|
||||
/// <summary>
|
||||
/// Gets the database context.
|
||||
/// </summary>
|
||||
protected DatabaseContext DatabaseContext { get; }
|
||||
|
||||
protected ApplicationContext ApplicationContext
|
||||
{
|
||||
get { return UmbracoContext.Application; }
|
||||
}
|
||||
protected DatabaseContext DatabaseContext
|
||||
{
|
||||
get { return ApplicationContext.DatabaseContext; }
|
||||
}
|
||||
protected ServiceContext Services
|
||||
{
|
||||
get { return ApplicationContext.Services; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the services context.
|
||||
/// </summary>
|
||||
protected ServiceContext Services { get; }
|
||||
|
||||
private UrlHelper _url;
|
||||
/// <summary>
|
||||
/// Returns a UrlHelper
|
||||
/// Gets a Url helper.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This URL helper is created without any route data and an empty request context
|
||||
/// </remarks>
|
||||
public UrlHelper Url
|
||||
{
|
||||
get { return _url ?? (_url = new UrlHelper(new RequestContext(new HttpContextWrapper(Context), new RouteData()))); }
|
||||
}
|
||||
|
||||
/// <remarks>This URL helper is created without any route data and an empty request context.</remarks>
|
||||
public UrlHelper Url => _url ?? (_url = new UrlHelper(new RequestContext(new HttpContextWrapper(Context), new RouteData())));
|
||||
}
|
||||
}
|
||||
@@ -4,10 +4,10 @@ using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using System.Web.UI;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Security;
|
||||
using umbraco.DataLayer;
|
||||
using Umbraco.Web.UI.Pages;
|
||||
|
||||
namespace Umbraco.Web.UI.Controls
|
||||
@@ -17,124 +17,95 @@ namespace Umbraco.Web.UI.Controls
|
||||
/// </summary>
|
||||
public abstract class UmbracoUserControl : UserControl
|
||||
{
|
||||
private ClientTools _clientTools;
|
||||
private UrlHelper _url;
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
/// <param name="umbracoContext"></param>
|
||||
protected UmbracoUserControl(UmbracoContext umbracoContext)
|
||||
/// <param name="services"></param>
|
||||
/// <param name="appCache"></param>
|
||||
protected UmbracoUserControl(UmbracoContext umbracoContext, ServiceContext services, CacheHelper appCache)
|
||||
{
|
||||
if (umbracoContext == null) throw new ArgumentNullException("umbracoContext");
|
||||
if (umbracoContext == null) throw new ArgumentNullException(nameof(umbracoContext));
|
||||
UmbracoContext = umbracoContext;
|
||||
InstanceId = Guid.NewGuid();
|
||||
Umbraco = new UmbracoHelper(umbracoContext);
|
||||
_membershipHelper = new MembershipHelper(umbracoContext);
|
||||
Umbraco = new UmbracoHelper(umbracoContext, services, appCache);
|
||||
Members = new MembershipHelper(umbracoContext);
|
||||
|
||||
// fixme inject somehow
|
||||
Logger = Current.Logger;
|
||||
ProfilingLogger = Current.ProfilingLogger;
|
||||
DatabaseContext = Current.DatabaseContext;
|
||||
Services = Current.Services;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Empty constructor, uses Singleton to resolve the UmbracoContext
|
||||
/// </summary>
|
||||
protected UmbracoUserControl()
|
||||
: this(UmbracoContext.Current)
|
||||
{
|
||||
}
|
||||
: this(Current.UmbracoContext, Current.Services, Current.ApplicationCache)
|
||||
{ }
|
||||
|
||||
// for debugging purposes
|
||||
internal Guid InstanceId { get; } = Guid.NewGuid();
|
||||
|
||||
private ClientTools _clientTools;
|
||||
/// <summary>
|
||||
/// Returns a refernce of an instance of ClientTools for access to the pages client API
|
||||
/// Gets the Umbraco helper.
|
||||
/// </summary>
|
||||
public UmbracoHelper Umbraco { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the membership helper;
|
||||
/// </summary>
|
||||
public MembershipHelper Members { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the web security helper.
|
||||
/// </summary>
|
||||
public WebSecurity Security => UmbracoContext.Security;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the logger.
|
||||
/// </summary>
|
||||
public ILogger Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the ProfilingLogger.
|
||||
/// </summary>
|
||||
public ProfilingLogger ProfilingLogger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Umbraco context.
|
||||
/// </summary>
|
||||
public UmbracoContext UmbracoContext { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the services context.
|
||||
/// </summary>
|
||||
public ServiceContext Services { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the database context.
|
||||
/// </summary>
|
||||
public DatabaseContext DatabaseContext { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets an instance of ClientTools for access to the pages client API.
|
||||
/// </summary>
|
||||
public ClientTools ClientTools
|
||||
{
|
||||
get
|
||||
{
|
||||
var page = Page as BasePage;
|
||||
return _clientTools ?? (_clientTools = (page != null) ? page.ClientTools : new ClientTools(Page));
|
||||
return _clientTools ?? (_clientTools = page != null ? page.ClientTools : new ClientTools(Page));
|
||||
}
|
||||
}
|
||||
|
||||
private readonly MembershipHelper _membershipHelper;
|
||||
|
||||
/// <summary>
|
||||
/// Useful for debugging
|
||||
/// Gets a Url helper.
|
||||
/// </summary>
|
||||
internal Guid InstanceId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns an UmbracoHelper object
|
||||
/// </summary>
|
||||
public UmbracoHelper Umbraco { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the MemberHelper instance
|
||||
/// </summary>
|
||||
public MembershipHelper Members
|
||||
{
|
||||
get { return _membershipHelper; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current WebSecurity instance
|
||||
/// </summary>
|
||||
public WebSecurity Security
|
||||
{
|
||||
get { return UmbracoContext.Security; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an ILogger
|
||||
/// </summary>
|
||||
public ILogger Logger
|
||||
{
|
||||
get { return ProfilingLogger.Logger; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a ProfilingLogger
|
||||
/// </summary>
|
||||
public ProfilingLogger ProfilingLogger
|
||||
{
|
||||
get { return UmbracoContext.Application.ProfilingLogger; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current UmbracoContext
|
||||
/// </summary>
|
||||
public UmbracoContext UmbracoContext { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current ApplicationContext
|
||||
/// </summary>
|
||||
public ApplicationContext ApplicationContext
|
||||
{
|
||||
get { return UmbracoContext.Application; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a ServiceContext
|
||||
/// </summary>
|
||||
public ServiceContext Services
|
||||
{
|
||||
get { return ApplicationContext.Services; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a DatabaseContext
|
||||
/// </summary>
|
||||
public DatabaseContext DatabaseContext
|
||||
{
|
||||
get { return ApplicationContext.DatabaseContext; }
|
||||
}
|
||||
|
||||
private UrlHelper _url;
|
||||
/// <summary>
|
||||
/// Returns a UrlHelper
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This URL helper is created without any route data and an empty request context
|
||||
/// </remarks>
|
||||
public UrlHelper Url
|
||||
{
|
||||
get { return _url ?? (_url = new UrlHelper(new RequestContext(new HttpContextWrapper(Context), new RouteData()))); }
|
||||
}
|
||||
|
||||
/// <remarks>This URL helper is created without any route data and an empty request context.</remarks>
|
||||
public UrlHelper Url => _url ?? (_url = new UrlHelper(new RequestContext(new HttpContextWrapper(Context), new RouteData())));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user