A nullable-enabled library of useful classes and extensions for supporting an Umbraco v10+ project.
A set of base controllers (and supporting classes) that expect an aggregate of dependencies:
public abstract class BaseSurfaceController : SurfaceController
{
protected readonly ILogger Logger;
protected readonly IViewRenderer ViewRenderer;
protected BaseSurfaceController(SurfaceControllerDependencies defaultDependencies) : base(
defaultDependencies.UmbracoContextAccessor,
defaultDependencies.DatabaseFactory,
defaultDependencies.Services,
defaultDependencies.AppCaches,
defaultDependencies.ProfilingLogger,
defaultDependencies.PublishedUrlProvider)
{
Logger = defaultDependencies.Logger;
ViewRenderer = defaultDependencies.ViewRenderer;
}
}
These include:
BaseController
BaseController<T>
BaseSurfaceController
BaseSurfaceController<T>
BaseVirtualController
BaseVirtualController<T>
Where <T>
allows for a strongly typed content model instead of IPublishedContent
.
There is also an extension method to register the supporting classes:
services.AddControllerDependencies();
A set of basic but useful extensions for making life just a little easier. These include:
TypeAlias()
Is(string alias)
GetDirtyProperties(content)
SetValueAsDocumentUdi(string alias, Guid contentKey)
SetValueAsMediaUdi(string alias, Guid contentKey)
SetValueAsMemberUdi(string alias, Guid contentKey)
SetValueAsElementUdi(string alias, Guid contentKey)
GetAllChildren(int parentId)
GetAllOfType(int contentTypeId)
ToUdi(string entityType = uConstants.UdiEntityType.Document)
GetPreviewId()
TryGetPreviewId()
IsPreviewPath()
IsReservedPath()
IsMediaPath()
TargetAsAttribute()
GetDirtyProperties()
ToIdentityUser(string memberTypeAlias, bool isApproved = true)
TypeAlias()
Is(string alias)
IsAny(params string[] alias)
HasTemplate()
HasAncestor(string docTypeAlias)
FirstSibling(content)
FirstSibling(string alias)
FirstSibling<T>(content)
PreviousSibling(content)
PreviousSibling(string alias)
PreviousSibling<T>(Func<T, bool>? filter = null)
LastSibling(content)
LastSibling(string alias)
LastSibling<T>(content)
NextSibling(Func<IPublishedbool>? filter = null)
NextSibling(string alias)
NextSibling<T>(Func<T, bool>? filter = null)
TypeAlias()
Is(string alias)
IsAny(params string[] alias)
ToGuid()