Special Methods

We've created a few special methods to help simplify your expressions.

OneOf Method

This string extension method is used to specify one or more values. Ideal replacement for using multiple or (||) conditions.

Evaluate by specifying multiple employee numbers:

Employee.EmployeeNumber.OneOf('001234,005678,009876')

Evaluate by specifying multiple cost center codes

CostCentre1.Level1.OneOf('MIA,LAX,JFK,LGA')

Evaluate by specifying multiple company names

Company.CompanyName.OneOf("Tesla,Microsoft,Amazon,Apple,Google")

 

NotOneOf Method

This string extension method is used to specify one or more values to exclude. Ideal replacement for using multiple or (||) conditions.

Evaluate by specifying multiple employee numbers

Employee.EmployeeNumber.NotOneOf('999901,999902,999903')

Evaluate by specifying multiple cost center codes

CostCentre1.Level1.NotOneOf('MIA,LAX,JFK,LGA')

Evaluate by specifying multiple company names

Company.CompanyName.NotOneOf("Tesla,Microsoft,Amazon,Apple,Google")

 

RemoveDiacritics Method

This string extension method is used to replace diacritical characters with their equivalent non-diacritical characters. 

Replace diacritic characters with non-diacritic characters

Person.FirstName.RemoveDiacritics()   

If the persons first name is Renée, it will be replaced with Renee.

If the persons first name is Amélie, it will be replaced with Amelie.

If the persons first name is Héloïse, it will be replaced  with Heloise.


RemoveWhiteSpace Method

This string extension method is used to remove white-space from a string.  

Remove white-space

Person.LastName.RemoveWhiteSpace()

If the persons last name is Van Patten, it will be changed to VanPatten.

If the persons last name is van der Sar, it will be replaced with vanderSar.

If the persons last name is Mc Donald, it will be replaced with McDonald. 


RemoveSpecialCharacters Method

This string extension method is used to remove special characters from a string.  

Remove special characters

Employment.DefaultJobTitle.RemoveSpecialCharacters()

If the job title is Sales & Marketing, it will be changed to Sales  Marketing.

If the job title is Tech/Support, it will be changed to TechSupport.

If the job title is **Finance**, it will be changed to Finance.

 

RemoveWhiteSpaceSpecialCharactersDiacritics Method

This string extension method nests the RemoveWhiteSpace(), RemoveSpecialCharacters() and RemoveDiacritics() methods into a single method for ease of use.  

Remove white-space, special characters and diacritics

Person.LastName.RemoveWhiteSpaceSpecialCharactersDiacritics()

If the persons last name is van der Woude's, it will be changed to vanderWoudes.

If the persons last name is Louis-Marie Lefèvre , it will be changed to LouisMarieLefevre.

 

ToTitleCase Method

This string extension method converts the specified string to title case.

Set the string to title case

Person.FirstName.ToTitleCase()

If the persons first name is JOHN, it will be changed to John.

If the persons first name is Louis marie, it will be changed to Louis Marie.

 

Generate Random Password Method

You can use GenerateRandomPassword() to return a string that can then be used for the default password for a user on account creation.

The method takes in 5 parameters which set different options for creating the password.

  • the length of the password
  • if lowercase letters should be included
  • if uppercase letters should be included
  • if numbers should be included
  • if special characters should be included

Generate a random password of length 8 that contains just lowercase letters and numbers

GenerateRandomPassword(8, true, false, true, false)

Generate a random password of length 14 that contains all types of characters

GenerateRandomPassword(14, true, true, true, true)

A value between 4 and 20 must be placed within the first parameter, a value outside that range will result in an error.

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.