Port v7@2aa0dfb2c5 - WIP

This commit is contained in:
Stephan
2018-03-27 16:18:51 +02:00
parent d40a835701
commit c2e1ba21b2
80 changed files with 8951 additions and 4462 deletions

View 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; }
}
}

View 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; }
}
}

View 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.");
}
}
}