diff --git a/src/SolutionInfo.cs b/src/SolutionInfo.cs
index 6162dd9db3..1a3d7f6902 100644
--- a/src/SolutionInfo.cs
+++ b/src/SolutionInfo.cs
@@ -12,4 +12,4 @@ using System.Resources;
[assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyFileVersion("7.8.0")]
-[assembly: AssemblyInformationalVersion("7.8.0-beta002")]
\ No newline at end of file
+[assembly: AssemblyInformationalVersion("7.8.0-beta003")]
\ No newline at end of file
diff --git a/src/Umbraco.Core/Collections/TypeList.cs b/src/Umbraco.Core/Collections/TypeList.cs
new file mode 100644
index 0000000000..37ca427ba1
--- /dev/null
+++ b/src/Umbraco.Core/Collections/TypeList.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+
+namespace Umbraco.Core.Collections
+{
+ ///
+ /// Represents a list of types.
+ ///
+ /// Types in the list are, or derive from, or implement, the base type.
+ /// The base type.
+ internal class TypeList
+ {
+ private readonly List _list = new List();
+
+ ///
+ /// Adds a type to the list.
+ ///
+ /// The type to add.
+ public void Add()
+ where T : TBase
+ {
+ _list.Add(typeof(T));
+ }
+
+ ///
+ /// Determines whether a type is in the list.
+ ///
+ public bool Contains(Type type)
+ {
+ return _list.Contains(type);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Properties/AssemblyInfo.cs b/src/Umbraco.Core/Properties/AssemblyInfo.cs
index 35ff0beb22..6c54d5c8b5 100644
--- a/src/Umbraco.Core/Properties/AssemblyInfo.cs
+++ b/src/Umbraco.Core/Properties/AssemblyInfo.cs
@@ -1,10 +1,8 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
-using System.Security;
-using System.Security.Permissions;
-// General Information about an assembly is controlled through the following
+// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Umbraco.Core")]
@@ -12,8 +10,8 @@ using System.Security.Permissions;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyProduct("Umbraco CMS")]
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
@@ -50,6 +48,8 @@ using System.Security.Permissions;
[assembly: InternalsVisibleTo("Umbraco.Forms.Core.Providers")]
[assembly: InternalsVisibleTo("Umbraco.Forms.Web")]
+[assembly: InternalsVisibleTo("Umbraco.Headless")]
+
//allow this to be mocked in our unit tests
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj
index 345ee8da8d..b470075a4d 100644
--- a/src/Umbraco.Core/Umbraco.Core.csproj
+++ b/src/Umbraco.Core/Umbraco.Core.csproj
@@ -178,6 +178,7 @@
+
diff --git a/src/Umbraco.Web/Features/DisabledFeatures.cs b/src/Umbraco.Web/Features/DisabledFeatures.cs
index 09b68f59fd..d771c101f4 100644
--- a/src/Umbraco.Web/Features/DisabledFeatures.cs
+++ b/src/Umbraco.Web/Features/DisabledFeatures.cs
@@ -1,18 +1,24 @@
-using Umbraco.Web.Trees;
+using Umbraco.Core.Collections;
using Umbraco.Web.WebApi;
namespace Umbraco.Web.Features
{
///
- /// Represents Umbraco features that can be disabled
+ /// Represents disabled features.
///
internal class DisabledFeatures
{
+ ///
+ /// Initializes a new instance of the class.
+ ///
public DisabledFeatures()
{
Controllers = new TypeList();
}
+ ///
+ /// Gets the disabled controllers.
+ ///
public TypeList Controllers { get; private set; }
}
}
\ No newline at end of file
diff --git a/src/Umbraco.Web/Features/FeaturesResolver.cs b/src/Umbraco.Web/Features/FeaturesResolver.cs
index e7dd5a4a88..cdb6fae9ea 100644
--- a/src/Umbraco.Web/Features/FeaturesResolver.cs
+++ b/src/Umbraco.Web/Features/FeaturesResolver.cs
@@ -4,21 +4,21 @@ namespace Umbraco.Web.Features
{
internal class FeaturesResolver : SingleObjectResolverBase
{
- public FeaturesResolver(UmbracoFeatures value) : base(value)
- {
- }
+ public FeaturesResolver(UmbracoFeatures value)
+ : base(value)
+ { }
+
///
- /// Sets the disabled features
+ /// Sets the features.
///
- ///
/// For developers, at application startup.
- public void SetFeatures(UmbracoFeatures finder)
+ public void SetFeatures(UmbracoFeatures features)
{
- Value = finder;
+ Value = features;
}
///
- /// Gets the features
+ /// Gets the features.
///
public UmbracoFeatures Features
{
diff --git a/src/Umbraco.Web/Features/TypeList.cs b/src/Umbraco.Web/Features/TypeList.cs
deleted file mode 100644
index f415b257f7..0000000000
--- a/src/Umbraco.Web/Features/TypeList.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using System;
-using System.Collections.Generic;
-
-namespace Umbraco.Web.Features
-{
- ///
- /// Maintains a list of strongly typed types
- ///
- ///
- internal class TypeList
- {
- private readonly List _disabled = new List();
-
- public void Add()
- where TType : T
- {
- _disabled.Add(typeof(TType));
- }
-
- public bool Contains(Type type)
- {
- return _disabled.Contains(type);
- }
- }
-}
\ No newline at end of file
diff --git a/src/Umbraco.Web/Features/UmbracoFeatures.cs b/src/Umbraco.Web/Features/UmbracoFeatures.cs
index 04bc6da363..5dc64ff5e4 100644
--- a/src/Umbraco.Web/Features/UmbracoFeatures.cs
+++ b/src/Umbraco.Web/Features/UmbracoFeatures.cs
@@ -1,17 +1,42 @@
+using System;
+using Umbraco.Web.WebApi;
+
namespace Umbraco.Web.Features
{
///
- /// Represents Umbraco features that can be toggled
+ /// Represents the Umbraco features.
///
internal class UmbracoFeatures
{
+ ///
+ /// Initializes a new instance of the class.
+ ///
public UmbracoFeatures()
{
- DisabledFeatures = new DisabledFeatures();
+ Disabled = new DisabledFeatures();
}
- public DisabledFeatures DisabledFeatures { get; set; }
+ // 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.
- //NOTE: Currently we can only Disable features but maybe some day we could enable non standard features too
+ ///
+ /// Gets the disabled features.
+ ///
+ public DisabledFeatures Disabled { get; set; }
+
+ ///
+ /// Determines whether a feature is enabled.
+ ///
+ public bool IsEnabled(Type feature)
+ {
+ if (typeof(UmbracoApiControllerBase).IsAssignableFrom(feature))
+ return Disabled.Controllers.Contains(feature) == false;
+
+ throw new NotSupportedException("Not a supported feature type.");
+ }
}
}
\ No newline at end of file
diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj
index 4b05f2956b..35b9dea9c4 100644
--- a/src/Umbraco.Web/Umbraco.Web.csproj
+++ b/src/Umbraco.Web/Umbraco.Web.csproj
@@ -337,7 +337,6 @@
-
@@ -799,7 +798,7 @@
-
+
diff --git a/src/Umbraco.Web/WebApi/Filters/FeaturesAuthorizeAttribute.cs b/src/Umbraco.Web/WebApi/Filters/FeatureAuthorizeAttribute.cs
similarity index 58%
rename from src/Umbraco.Web/WebApi/Filters/FeaturesAuthorizeAttribute.cs
rename to src/Umbraco.Web/WebApi/Filters/FeatureAuthorizeAttribute.cs
index 4148c61a03..58495a06b3 100644
--- a/src/Umbraco.Web/WebApi/Filters/FeaturesAuthorizeAttribute.cs
+++ b/src/Umbraco.Web/WebApi/Filters/FeatureAuthorizeAttribute.cs
@@ -5,14 +5,15 @@ using Umbraco.Web.Features;
namespace Umbraco.Web.WebApi.Filters
{
///
- /// Will return unauthorized for the controller if it's been globally disabled
+ /// Ensures that the controller is an authorized feature.
///
- public sealed class FeaturesAuthorizeAttribute : AuthorizeAttribute
+ /// Else returns unauthorized.
+ public sealed class FeatureAuthorizeAttribute : AuthorizeAttribute
{
protected override bool IsAuthorized(HttpActionContext actionContext)
{
var controllerType = actionContext.ControllerContext.ControllerDescriptor.ControllerType;
- return FeaturesResolver.Current.Features.DisabledFeatures.Controllers.Contains(controllerType) == false;
+ return FeaturesResolver.Current.Features.IsEnabled(controllerType);
}
}
}
\ No newline at end of file
diff --git a/src/Umbraco.Web/WebApi/UmbracoApiControllerBase.cs b/src/Umbraco.Web/WebApi/UmbracoApiControllerBase.cs
index c39ee9fce3..48b1bc5d46 100644
--- a/src/Umbraco.Web/WebApi/UmbracoApiControllerBase.cs
+++ b/src/Umbraco.Web/WebApi/UmbracoApiControllerBase.cs
@@ -13,7 +13,7 @@ namespace Umbraco.Web.WebApi
///
/// The base class for API controllers that expose Umbraco services - THESE ARE NOT AUTO ROUTED
///
- [FeaturesAuthorize]
+ [FeatureAuthorize]
public abstract class UmbracoApiControllerBase : ApiController
{
protected UmbracoApiControllerBase()