Exemple #1
0
        internal static IMatch ParseFilterParameter(string filterParameter, out string error)
        {
            error = null;
            if (!Regex.IsMatch(filterParameter, "Description\\s+-like\\s+", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
            {
                error = Strings.InvalidRuleSearchFilterMissingElements;
                return(null);
            }
            Regex regex = new Regex(string.Format("Description\\s+-like\\s+(\"|')(?<{0}>.*)(\"|')", "theFilter"), RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
            Match match = regex.Match(filterParameter);

            if (match.Groups["theFilter"] != null)
            {
                string text = regex.Match(filterParameter).Groups["theFilter"].Value.Trim();
                if (string.IsNullOrEmpty(text))
                {
                    error = Strings.InvalidRuleSearchFilterEmpty;
                    return(null);
                }
                MatchFactory matchFactory = new MatchFactory();
                try
                {
                    return(matchFactory.CreateRegex(GetTransportRule.FilterStringToRegex(text), false, false));
                }
                catch (ArgumentException ex)
                {
                    error = (string.IsNullOrWhiteSpace(ex.Message) ? "Unknown Error" : ex.Message);
                    return(null);
                }
            }
            error = Strings.InvalidRuleSearchFilterEmpty;
            return(null);
        }
Exemple #2
0
 protected override void InternalValidate()
 {
     if (base.OptionalIdentityData != null)
     {
         base.OptionalIdentityData.ConfigurationContainerRdn = RuleIdParameter.GetRuleCollectionRdn(this.ruleCollectionName);
     }
     if (base.Fields["Filter"] != null)
     {
         if (base.Fields["Identity"] != null)
         {
             base.WriteError(new ArgumentException(Strings.IncompatibleGetTransportRuleParameters("Identity", "Filter")), ErrorCategory.InvalidArgument, "Filter");
         }
         string errorMessage;
         this.searchFilter = GetTransportRule.ParseFilterParameter((string)base.Fields["Filter"], out errorMessage);
         if (this.searchFilter == null)
         {
             base.WriteError(new ArgumentException(Strings.InvalidRuleSearchFilter((string)base.Fields["Filter"], errorMessage)), ErrorCategory.InvalidArgument, "Filter");
         }
     }
     base.InternalValidate();
 }