szabototo89 / CodeSharper

Refactoring tool, written in C# and using TDD for developing
2 stars 0 forks source link

[idea] Fluent Is-Style API Design #27

Open szabototo89 opened 10 years ago

szabototo89 commented 10 years ago

I should implement Helpers method as fluent style:

bool isUpperCase = "Hello World".Is.UpperCase;
bool isBlank = "Hello".Is.Blank;
bool isNotNull = "Hi".Is.Not.Null;

public class Utility<T> {
   public String Value { get; protected set; }
   public Utility(T value) { Value = value; }
}

public class StringUtility : Utility<String> { }

public static class StringHelper {
   public static StringUtility<String> Is(this String that) {
      return new StringUtility(that);
   }
}

Advantages: