+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Does the personalization IPAddress characteristic support wildcards?

Does the personalization IPAddress characteristic support wildcards?

3 posts, 1 answered
  1. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    28 Oct 2014
    Link to this post

    We need to have a segment for users in certain buildings\ip ranges...the verbage in the UI is

    "IP Address is(or is not) X"...no contains or anything

     Any idea?

  2. Ivan
    Ivan avatar
    1 posts
    Registered:
    13 Aug 2011
    28 Oct 2014
    Link to this post

    No it does not.

    That being said, it's rather trivial to make it so. Create a new class, let's say AwesomeIpEvaluator and have it implement ICriterionEvaluator. Implement the interface... the trick is in the IsMatch function - the first argument "settings" is what user entered in the UI, so that could be one or more IP addresses. Do some RegEx magic and return true if it's a match, otherwise false.

    Finally, you need to replace the default IpAddressEvaluator. You can do this through DI, like this:

    ObjectFactory.Container.RegisterType(
      typeof(ICriterionEvaluator),
      typeof(AwesomeIpEvalutator), // your new evaluator
      PersonalizationConstants.CriteriaName.IPAddress, // name of the evaluator
      new ContainerControlledLifetimeManager(),
      new InjectionConstructor());

    Answered
  3. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    29 Oct 2014 in reply to Ivan
    Link to this post
    Trivial indeed, and great evaluator name :)
3 posts, 1 answered