Created
January 29, 2021 21:48
-
-
Save NickPolyder/5fcd2d4849e642aa4e509397a59eacca to your computer and use it in GitHub Desktop.
Factory Pattern C#
This file contains hidden or 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 interface IUser | |
{ | |
string Username { get; } | |
// rest of the properties | |
} | |
public interface IUserFactory | |
{ | |
IUser CreateUser(UserState userState); | |
} | |
public TwitchUserFactory : IUserFactory | |
{ | |
public IUser CreateUser(UserState userState) | |
{ | |
// You can include more information here or validations | |
return new TwitchUser(userState); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment