public static bool Evaluate(TriggerPart triggerPart, NameValueCollection httpHeaders)
 {
     return(ComparisonOperatorHelper.Evaluate(triggerPart.Operator,
                                              triggerPart.IsNegative,
                                              triggerPart.IsIgnoreCase,
                                              httpHeaders?.Get(triggerPart.HttpHeaderName) ?? string.Empty,
                                              triggerPart.ValueToCompare,
                                              triggerPart.ValuesToCompare));
 }
 public static bool Evaluate(TriggerPart triggerPart, string userAgent)
 {
     return(ComparisonOperatorHelper.Evaluate(triggerPart.Operator,
                                              triggerPart.IsNegative,
                                              triggerPart.IsIgnoreCase,
                                              userAgent ?? string.Empty,
                                              triggerPart.ValueToCompare,
                                              triggerPart.ValuesToCompare));
 }
 public static bool Evaluate(TriggerPart triggerPart, IHttpRequest request)
 {
     return(ComparisonOperatorHelper.Evaluate(triggerPart.Operator,
                                              triggerPart.IsNegative,
                                              triggerPart.IsIgnoreCase,
                                              GetCookie(triggerPart.CookieName, request),
                                              triggerPart.ValueToCompare,
                                              triggerPart.ValuesToCompare));
 }
 public static bool Evaluate(TriggerPart triggerPart, string url)
 {
     return(ComparisonOperatorHelper.Evaluate(
                triggerPart.Operator,
                triggerPart.IsNegative,
                triggerPart.IsIgnoreCase,
                GetUrlPart(triggerPart, url),
                triggerPart.ValueToCompare,
                triggerPart.ValuesToCompare));
 }
        private static string GetUrlPart(TriggerPart triggerPart, string url)
        {
            switch (triggerPart.UrlPart)
            {
            case UrlPartType.PagePath:
                return(GetPathFromUrl(url));

            case UrlPartType.PageUrl:
                return(url);

            case UrlPartType.HostName:
                return(GetHostNameFromUrl(url));

            default:
                return(string.Empty);
            }
        }
        private bool EvaluateTriggerPart(TriggerPart triggerPart, string currentPageUrl, IHttpRequest request)
        {
            switch (triggerPart.ValidatorType)
            {
            case ValidatorType.UrlValidator:
                return(UrlValidatorHelper.Evaluate(triggerPart, currentPageUrl));

            case ValidatorType.CookieValidator:
                return(CookieValidatorHelper.Evaluate(triggerPart, request));

            case ValidatorType.UserAgentValidator:
                return(UserAgentValidatorHelper.Evaluate(triggerPart, request.UserAgent));

            case ValidatorType.HttpHeaderValidator:
                return(HttpHeaderValidatorHelper.Evaluate(triggerPart, request.Headers));

            default:
                return(false);
            }
        }