Skip to content

Instantly share code, notes, and snippets.

@NickPolyder
Created January 29, 2021 21:48
Show Gist options
  • Save NickPolyder/5fcd2d4849e642aa4e509397a59eacca to your computer and use it in GitHub Desktop.
Save NickPolyder/5fcd2d4849e642aa4e509397a59eacca to your computer and use it in GitHub Desktop.
Factory Pattern C#
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