Created
September 28, 2017 10:16
-
-
Save NMZivkovic/bdda7584dee802a2e804b10ae70e96c4 to your computer and use it in GitHub Desktop.
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 class EntityFactory | |
{ | |
private Dictionary<EntityType, Func<entity>> _entityTypeMapper; | |
public EntityFactory() | |
{ | |
_entityTypeMapper = new Dictionary<entitytype, func<entity="">>(); | |
_entityTypeMapper.Add(EntityType.Type0, () => { return new Type0Entity(); }); | |
_entityTypeMapper.Add(EntityType.Type1, () => { return new Type1Entity(); }); | |
_entityTypeMapper.Add(EntityType.Type2, () => { return new Type2Entity(); }); | |
} | |
public Entity GetEntityBasedOnType(EntityType entityType) | |
{ | |
return _entityTypeMapper[entityType](); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment