Last active
January 17, 2019 19:04
-
-
Save jeffreyschultz/2133001951d081e7a7e6ecc661752fc2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Builder<T> | |
{ | |
public Builder() | |
{ | |
Controller = new BuilderStep<Controller>(this); | |
} | |
public BuilderStep<ListingSearchController> Controller { get; } | |
public T Build() | |
{ | |
return default(T); | |
} | |
public class BuilderStep<TValueType> | |
{ | |
public BuilderStep(Builder<T> builder) | |
{ | |
Builder = builder ?? throw new ArgumentNullException(nameof(builder)); | |
} | |
public Builder<T> Set(TValueType value) | |
{ | |
Value = value; | |
return Builder; | |
} | |
protected TValueType Value { get; set; } | |
protected Builder<T> Builder { get; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The BuilderStep class should be extended to add a lambda that will be used to handle the actual assigned, and also accept a boolean that determines whether the value is required or not. This way the builder base classes can be generalized to support assignment and validation of the values without having to use reflection.