public IList <ControlResult> Evaluate(IList <ResourceControlSet> resourceControlSets, JObject resource)
        {
            var type = resource.GetValueCaseInsensitive <string>("type");
            //var apiVersion = resource.GetValueCaseInsensitive<string>("apiVersion");
            var controlSet = resourceControlSets?.FirstOrDefault(
                x => x.supportedResourceTypes.Any(y => y.Equals(type, StringComparison.OrdinalIgnoreCase)));

            if (controlSet == null)
            {
                return(new List <ControlResult> {
                    ControlResult.NotSupported(resource)
                });
            }
            var results = new List <ControlResult>();

            foreach (var control in controlSet.Controls)
            {
                control.FeatureName        = controlSet.FeatureName;
                control.SupportedResources = controlSet.supportedResourceTypes.ToArray().ToSingleString(" , ");
                var controlResult = _controlEvaluator.Evaluate(control, resource);
                results.Add(controlResult);
            }
            EvaluateNestedResources(controlSet, resource, results);
            return(results);
        }
        public ControlResult Evaluate(ResourceControl control, JObject resource)
        {
            switch (control.MatchType)
            {
            case ControlMatchType.Null:
                return(ControlResult.NotSupported(resource));

            case ControlMatchType.Boolean:
                return(EvaluateBoolean(control, resource));

            case ControlMatchType.IntegerValue:
                return(EvaluateIntegerValue(control, resource));

            case ControlMatchType.ItemCount:
                return(EvaluateItemCount(control, resource));

            case ControlMatchType.ItemProperties:
                return(EvaluateItemProperties(control, resource));

            case ControlMatchType.SecureParam:
                return(EvaluateSecureParam(control, resource));

            case ControlMatchType.StringLength:
                return(ControlResult.NotSupported(resource));

            case ControlMatchType.StringWhitespace:
                return(EvaluateStringWhitespace(control, resource));

            case ControlMatchType.StringSingleToken:
                return(EvaluateStringSingleToken(control, resource));

            case ControlMatchType.StringMultiToken:
                return(EvaluateStringMultiToken(control, resource));

            case ControlMatchType.RegExpressionSingleToken:
                return(EvaluateRegExpressionSingleToken(control, resource));

            case ControlMatchType.RegExpressionMultiToken:
                return(ControlResult.NotSupported(resource));

            case ControlMatchType.VerifiableSingleToken:
                return(EvaluateVerifiableSingleToken(control, resource));

            case ControlMatchType.VerifiableMultiToken:
                return(ControlResult.NotSupported(resource));

            case ControlMatchType.Custom:
                return(ControlResult.NotSupported(resource));

            case ControlMatchType.NullableSingleToken:
                return(EvaluateNullableSingleToken(control, resource));

            case ControlMatchType.VersionSingleToken:
                return(EvaluateSingleVersionToken(control, resource));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }