using System; using System.Web.UI; using Umbraco.Core; using Umbraco.Core.Services; namespace Umbraco.Web { /// /// A base class for all Presentation UserControls to inherit from /// public abstract class UmbracoUserControl : UserControl { /// /// Default constructor /// /// protected UmbracoUserControl(UmbracoContext umbracoContext) { if (umbracoContext == null) throw new ArgumentNullException("umbracoContext"); UmbracoContext = umbracoContext; InstanceId = Guid.NewGuid(); Umbraco = new UmbracoHelper(umbracoContext); } /// /// Empty constructor, uses Singleton to resolve the UmbracoContext /// protected UmbracoUserControl() : this(UmbracoContext.Current) { } /// /// Useful for debugging /// internal Guid InstanceId { get; private set; } /// /// Returns an UmbracoHelper object /// public UmbracoHelper Umbraco { get; private set; } /// /// Returns the current UmbracoContext /// public UmbracoContext UmbracoContext { get; private set; } /// /// Returns the current ApplicationContext /// public ApplicationContext ApplicationContext { get { return UmbracoContext.Application; } } /// /// Returns a ServiceContext /// public ServiceContext Services { get { return ApplicationContext.Services; } } /// /// Returns a DatabaseContext /// public DatabaseContext DatabaseContext { get { return ApplicationContext.DatabaseContext; } } } }