/// <summary>
    ///     Helper method to create a new form to execute in the Umbraco request pipeline to a surface controller plugin
    /// </summary>
    public static MvcForm BeginUmbracoForm(
        this IHtmlHelper html,
        string action,
        Type surfaceType,
        object?additionalRouteVals,
        IDictionary <string, object?> htmlAttributes,
        FormMethod method)
    {
        if (action == null)
        {
            throw new ArgumentNullException(nameof(action));
        }

        if (string.IsNullOrWhiteSpace(action))
        {
            throw new ArgumentException(
                      "Value can't be empty or consist only of white-space characters.",
                      nameof(action));
        }

        if (surfaceType == null)
        {
            throw new ArgumentNullException(nameof(surfaceType));
        }

        SurfaceControllerTypeCollection surfaceControllerTypeCollection =
            GetRequiredService <SurfaceControllerTypeCollection>(html);
        Type?surfaceController = surfaceControllerTypeCollection.SingleOrDefault(x => x == surfaceType);

        if (surfaceController == null)
        {
            throw new InvalidOperationException("Could not find the surface controller of type " +
                                                surfaceType.FullName);
        }

        PluginControllerMetadata metaData = PluginController.GetMetadata(surfaceController);

        var area = string.Empty;

        if (metaData.AreaName.IsNullOrWhiteSpace() == false)
        {
            // Set the area to the plugin area
            area = metaData.AreaName;
        }

        return(html.BeginUmbracoForm(
                   action,
                   metaData.ControllerName,
                   area !,
                   additionalRouteVals,
                   htmlAttributes,
                   method));
    }
    /// <summary>
    ///     Returns the result of a child action of a SurfaceController
    /// </summary>
    public static IHtmlContent ActionLink(this IHtmlHelper htmlHelper, string actionName, Type surfaceType)
    {
        if (actionName == null)
        {
            throw new ArgumentNullException(nameof(actionName));
        }

        if (string.IsNullOrWhiteSpace(actionName))
        {
            throw new ArgumentException(
                      "Value can't be empty or consist only of white-space characters.",
                      nameof(actionName));
        }

        if (surfaceType == null)
        {
            throw new ArgumentNullException(nameof(surfaceType));
        }

        SurfaceControllerTypeCollection surfaceControllerTypeCollection =
            GetRequiredService <SurfaceControllerTypeCollection>(htmlHelper);
        Type?surfaceController = surfaceControllerTypeCollection.SingleOrDefault(x => x == surfaceType);

        if (surfaceController == null)
        {
            throw new InvalidOperationException("Could not find the surface controller of type " +
                                                surfaceType.FullName);
        }

        var routeVals = new RouteValueDictionary(new { area = string.Empty });

        PluginControllerMetadata metaData = PluginController.GetMetadata(surfaceController);

        if (!metaData.AreaName.IsNullOrWhiteSpace())
        {
            // set the area to the plugin area
            if (routeVals.ContainsKey("area"))
            {
                routeVals["area"] = metaData.AreaName;
            }
            else
            {
                routeVals.Add("area", metaData.AreaName);
            }
        }

        return(htmlHelper.ActionLink(actionName, metaData.ControllerName, routeVals));
    }