Does the personalization IPAddress characteristic support wi

Posted by Community Admin on 03-Aug-2018 17:48

Does the personalization IPAddress characteristic support wildcards?

All Replies

Posted by Community Admin on 28-Oct-2014 00:00

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?

Posted by Community Admin on 28-Oct-2014 00:00

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());

Posted by Community Admin on 29-Oct-2014 00:00

Trivial indeed, and great evaluator name :)

This thread is closed