Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. public class NotBeginsWithFunction : ICustomFunctionDisplayAttributes {
  2. public const string FunctionName = "NotBeginsWith";
  3. static readonly NotBeginsWithFunction instance = new NotBeginsWithFunction();
  4. public static void Register() {
  5. CriteriaOperator.RegisterCustomFunction(instance);
  6. }
  7. public static bool Unregister() {
  8. return CriteriaOperator.UnregisterCustomFunction(instance);
  9. }
  10.  
  11. public string Name => FunctionName;
  12. public string DisplayName => "Does not begin with";
  13. public object Image => "FontSizeDecrease;Office2013";
  14. public string Description => "Hides records when the field begins with the given value";
  15. public FunctionCategory Category => FunctionCategory.Text;
  16.  
  17. public int MinOperandCount => 2;
  18. public int MaxOperandCount => 2;
  19. public bool IsValidOperandCount(int count) => count == 2;
  20. public bool IsValidOperandType(int operandIndex, int operandCount, Type type) =>
  21. typeof(string);
  22. public Type ResultType(params Type[] operands) => typeof(bool);
  23.  
  24. public object Evaluate(params object[] operands) {
  25. if(operands[0] != null && operands[1] != null) {
  26. string str1 = operands[0].ToString();
  27. string str2 = operands[1].ToString();
  28. return !str1.StartsWith(str2, StringComparison.InvariantCultureIgnoreCase);
  29. }
  30. return false;
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement