public ProductType Create(IdType id) { if (factoryCreators.ContainsKey(id)) { IAbstractCreator creator = factoryCreators[id]; return((ProductType)creator.Create()); } return(default(ProductType)); }
public void Register(IdType id, IAbstractCreator creator) { if (creator != null) { factoryCreators[id] = creator; if (Registered != null) { Registered(id); } } }
public void Unregister(IAbstractCreator creator) { int index = factoryCreators.IndexOfValue(creator); if (index != -1) { factoryCreators.RemoveAt(index); if (Unregistered != null) { IdType id = factoryCreators.Keys[index]; Unregistered(id); } } }