Opimizely | .NET | Angular

Michal Toman


public partial class Foo // <-- Make the class a partial class

{

[RegexGenerator(@"abc|def", RegexOptions.IgnoreCase)] // <-- Add the RegexGenerator attribute and pass in your pattern and options

public static partial Regex MyRegex(); // <-- Declare the partial method, which will be implemented by the source generator


public bool Bar(string input)

{

bool isMatch = MyRegex().IsMatch(input); // <-- Use the generated engine by invoking the partial method.

// ..

}

}