Port v7@2aa0dfb2c5 - WIP
This commit is contained in:
24
src/Umbraco.Web/Features/DisabledFeatures.cs
Normal file
24
src/Umbraco.Web/Features/DisabledFeatures.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using Umbraco.Core.Collections;
|
||||
using Umbraco.Web.WebApi;
|
||||
|
||||
namespace Umbraco.Web.Features
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents disabled features.
|
||||
/// </summary>
|
||||
internal class DisabledFeatures
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DisabledFeatures"/> class.
|
||||
/// </summary>
|
||||
public DisabledFeatures()
|
||||
{
|
||||
Controllers = new TypeList<UmbracoApiControllerBase>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the disabled controllers.
|
||||
/// </summary>
|
||||
public TypeList<UmbracoApiControllerBase> Controllers { get; }
|
||||
}
|
||||
}
|
||||
14
src/Umbraco.Web/Features/EnabledFeatures.cs
Normal file
14
src/Umbraco.Web/Features/EnabledFeatures.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace Umbraco.Web.Features
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents enabled features.
|
||||
/// </summary>
|
||||
internal class EnabledFeatures
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies if rendering pipeline should ignore HasTemplate check when handling a request.
|
||||
/// <remarks>This is to allow JSON preview of content with no template set.</remarks>
|
||||
/// </summary>
|
||||
public bool RenderNoTemplate { get; set; }
|
||||
}
|
||||
}
|
||||
48
src/Umbraco.Web/Features/UmbracoFeatures.cs
Normal file
48
src/Umbraco.Web/Features/UmbracoFeatures.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using Umbraco.Web.WebApi;
|
||||
|
||||
namespace Umbraco.Web.Features
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the Umbraco features.
|
||||
/// </summary>
|
||||
internal class UmbracoFeatures
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UmbracoFeatures"/> class.
|
||||
/// </summary>
|
||||
public UmbracoFeatures()
|
||||
{
|
||||
Disabled = new DisabledFeatures();
|
||||
Enabled = new EnabledFeatures();
|
||||
}
|
||||
|
||||
// note
|
||||
// currently, the only thing a FeatureSet does is list disabled controllers,
|
||||
// but eventually we could enable and disable more parts of Umbraco. and then
|
||||
// we would need some logic to figure out what's enabled/disabled - hence it's
|
||||
// better to use IsEnabled, where the logic would go, rather than directly
|
||||
// accessing the Disabled collection.
|
||||
|
||||
/// <summary>
|
||||
/// Gets the disabled features.
|
||||
/// </summary>
|
||||
public DisabledFeatures Disabled { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the enabled features.
|
||||
/// </summary>
|
||||
public EnabledFeatures Enabled { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether a feature is enabled.
|
||||
/// </summary>
|
||||
public bool IsEnabled(Type feature)
|
||||
{
|
||||
if (typeof(UmbracoApiControllerBase).IsAssignableFrom(feature))
|
||||
return Disabled.Controllers.Contains(feature) == false;
|
||||
|
||||
throw new NotSupportedException("Not a supported feature type.");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user